Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:38:34+00:00 2026-06-18T10:38:34+00:00

I’m trying to come up with an algorithm that will determine turning points in

  • 0

I’m trying to come up with an algorithm that will determine turning points in a trajectory of x/y coordinates. The following figures illustrates what I mean: green indicates the starting point and red the final point of the trajectory (the entire trajectory consists of ~ 1500 points):
trajectory

In the following figure, I added by hand the possible (global) turning points that an algorithm could return:

trajectory with possible turning points

Obviously, the true turning point is always debatable and will depend on the angle that one specifies that has to lie between points. Furthermore a turning point can be defined on a global scale (what I tried to do with the black circles), but could also be defined on a high-resolution local scale. I’m interested in the global (overall) direction changes, but I’d love to see a discussion on the different approaches that one would use to tease apart global vs local solutions.

What I’ve tried so far:

  • calculate distance between subsequent points
  • calculate angle between subsequent points
  • look how distance / angle changes between subsequent points

Unfortunately this doesn’t give me any robust results. I probably have too calculate the curvature along multiple points, but that’s just an idea.
I’d really appreciate any algorithms / ideas that might help me here. The code can be in any programming language, matlab or python are preferred.

EDIT here’s the raw data (in case somebody want’s to play with it):

  • mat file
  • text file (x coordinate first, y coordinate in second line)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:38:35+00:00Added an answer on June 18, 2026 at 10:38 am

    You could use the Ramer-Douglas-Peucker (RDP) algorithm to simplify the path. Then you could compute the change in directions along each segment of the simplified path. The points corresponding to the greatest change in direction could be called the turning points:

    A Python implementation of the RDP algorithm can be found on github.

    import matplotlib.pyplot as plt
    import numpy as np
    import os
    import rdp
    
    def angle(dir):
        """
        Returns the angles between vectors.
    
        Parameters:
        dir is a 2D-array of shape (N,M) representing N vectors in M-dimensional space.
    
        The return value is a 1D-array of values of shape (N-1,), with each value
        between 0 and pi.
    
        0 implies the vectors point in the same direction
        pi/2 implies the vectors are orthogonal
        pi implies the vectors point in opposite directions
        """
        dir2 = dir[1:]
        dir1 = dir[:-1]
        return np.arccos((dir1*dir2).sum(axis=1)/(
            np.sqrt((dir1**2).sum(axis=1)*(dir2**2).sum(axis=1))))
    
    tolerance = 70
    min_angle = np.pi*0.22
    filename = os.path.expanduser('~/tmp/bla.data')
    points = np.genfromtxt(filename).T
    print(len(points))
    x, y = points.T
    
    # Use the Ramer-Douglas-Peucker algorithm to simplify the path
    # http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
    # Python implementation: https://github.com/sebleier/RDP/
    simplified = np.array(rdp.rdp(points.tolist(), tolerance))
    
    print(len(simplified))
    sx, sy = simplified.T
    
    # compute the direction vectors on the simplified curve
    directions = np.diff(simplified, axis=0)
    theta = angle(directions)
    # Select the index of the points with the greatest theta
    # Large theta is associated with greatest change in direction.
    idx = np.where(theta>min_angle)[0]+1
    
    fig = plt.figure()
    ax =fig.add_subplot(111)
    
    ax.plot(x, y, 'b-', label='original path')
    ax.plot(sx, sy, 'g--', label='simplified path')
    ax.plot(sx[idx], sy[idx], 'ro', markersize = 10, label='turning points')
    ax.invert_yaxis()
    plt.legend(loc='best')
    plt.show()
    

    enter image description here

    Two parameters were used above:

    1. The RDP algorithm takes one parameter, the tolerance, which
      represents the maximum distance the simplified path
      can stray from the original path. The larger the tolerance, the cruder the simplified path.
    2. The other parameter is the min_angle which defines what is considered a turning point. (I’m taking a turning point to be any point on the original path, whose angle between the entering and exiting vectors on the simplified path is greater than min_angle).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.