0

I want to generate a vector of spherical (Earth) coordinates that would draw an arc given center location (in longitude latitude), radius (in meters), azimuth, and angle width (in radians).

My code:

double left = azimuth - width * .5;
double right = azimuth + width * .5;
double angleStep = 0.05;
std::vector<double> arcPointsX, arcPointsY;

for (double f = left; f <= right; f += angleStep) {   
    arcPointsX.push_back(x + radius * (double)cos(f));
    arcPointsY.push_back(y + radius * (double)sin(f));
}

This produces arcs however, these arcs are not facing the correct direction when I draw them though.

Thanks for help!

5
  • How are you using xa1, ya1, xa2, and ya2?
    – R Sahu
    Apr 3, 2014 at 3:01
  • same way as arcPointsX and arcPointsY, they should not really be there, I will modify the code.
    – Jana
    Apr 3, 2014 at 3:44
  • What are X and Y? You seem to be drawing an arc in the plane passing through the equator, not the surface of the Earth.
    – Beta
    Apr 3, 2014 at 3:49
  • X,Y is the circle center location in longitude latitude
    – Jana
    Apr 3, 2014 at 17:13
  • You're trying to do too much at once. Are you comfortable with coordinate conversions between spherical (lat, lon) and Cartesian (x,y,z)?
    – Beta
    Apr 4, 2014 at 11:46

1 Answer 1

1

It turned out the problem was I had sin/cos the other way around. Using this gives me correct arcs:

arcPointsX.push_back(x + radius * (double)sin(f));
arcPointsY.push_back(y + radius * (double)cos(f));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.