Menu

Calculating equidistant points along a Archimedes like spiral

Anonymous
2020-05-07
2020-05-24
  • Anonymous

    Anonymous - 2020-05-07

    I know how to plot a simple spiral in c/c++ for a truly simple example in carthesian co-ordinates I see something like the following:

    https://computergraphics.stackexchange.com/questions/1820/archimedean-spiral-in-c

    What I would like to do is to create a spiral shaped flight plan centered on some Lat/Lon and calculate equidistant points along this spiral (each one of which will be a waypoint for the flight). I know a section of a spiral curve is not a geodesic, but can you think of a simple approach I could use to do such a thing? I'm trying to create a test case that contains mathematically generated flight paths for testing navigation code and the flight would be broken up into geodesic segments between these points.

    Thanks

    John

     
  • Charles Karney

    Charles Karney - 2020-05-07

    No point in overthinking this, surely... So how about the following
    MATLAB function

    function spiral(lat0, lon0, a, b, thetamin, thetamax)
      theta = [thetamin:5:thetamax];
      r = a+b*theta*pi/180;
      [lat,lon] = geodreckon(lat0, lon0, r, theta);
      plot(lon, lat)
    end
    
     
  • Anonymous

    Anonymous - 2020-05-17

    Charles, Thanks, I haven't used matlab before, and I am not sure how I would integrate matlab calulated lat/lons into my Qt based C++ GUI - My 'along the curve' equidistance requirements are very loose, as I was trying to come up with a GUI controlled way (possibly using just the 'a' and 'b' terms of the more general 3 variable archimedian spiral curve) to generate waypoints from a few Gui controls. I'm throwing together a quick and dirty carthesian x/y spiral generator using OpenGL as a sort of experimental sandbox - it would be great if I could convert the simple x,y carthesian co-ordinates to geodesic ones without being too concerned with the geodesic nature of the lines.

    John Coffey

     
  • Charles Karney

    Charles Karney - 2020-05-17

    I just listed the MATLAB solution as an illustration. You can easily convert this to C++ code calling the GeographicLib C++ library.

     
  • Anonymous

    Anonymous - 2020-05-17

    Thanks, I was just looking into that. From what I can tell the function geodrekon (matlab code) is similar - but not the same as geodesic direct. (I didnt see geodrekon in the C++ library API).

    I am having trouble understanding how to implement

    [lat,lon] = geodreckon(lat0, lon0, r, theta) in C++ using the Direct call.

    If I was to guess, I would pass in 'r' in place of 's12', but then I am not sure how I would calculate 'azi1' at my lat/lon (perhaps that is the 'theta' or as we are talking about azimith angles, maybe I have to add 90 degrees.

    Also, when 'a' is zero, (the spiral effectively rotates around a center point rather than 'a' units to the right (on a cartesian x axis), the points 5 degrees apart (in the matlab example) are very close initially, and are more evenly separated as we emanate away from the center. Perhaps in order to calculate (for example 100nm separated waypoints along this spiral, I would have to make fine delta thetas and add up the geodesic inverse solutions along the curve to find the nearest matches. Again this doesn't have to be totally accurate.

    John Coffey

     
  • Charles Karney

    Charles Karney - 2020-05-24

    Yes, r is s12 and theta is azi1 (which is measure clockwise from
    north). No, nonzero a does not displace the spiral in the x
    direction.

    In order to find the approximate distance two close points on the
    spiral, you would compute the hypotenuse of a right triangle where one
    edge is the change is s12 and the other edge is m12 (not s12)
    multiplied by the change in theta (in radians, of course). This
    should allow you to adjust the steps in theta you need to take.

     

Anonymous
Anonymous

Add attachments
Cancel