0

I have a series of lat/lon which represents the center of some object. I need to draw a line through this point that is x meters on either side of the center and it needs to be perpendicular to the heading (imagine a capital T)

Ultimately I want to get the lat/lon of this line's endpoints.

Thanks!

Tim Reddy
  • 4,210
  • 1
  • 36
  • 72

2 Answers2

2

The basic calculation is in this similar question's answer: Calculate second point knowing the starting point and distance. Calculate the points for the two headings perpendicular to the main heading the distance away you want.

Community
  • 1
  • 1
Brian
  • 6,085
  • 2
  • 22
  • 28
1

Have a look at: Core Location extensions for bearing and distance

With those extensions and two points on the initial line you should be able to get the bearing, add/subtract pi/2 and find points to either side like this:

double bearing = [bottomOfT bearingInRadiansTowardsLocation:topOfT];
CLLocation *left = [topOfT newLocationAtDistance:meters
                             alongBearingradians:bearing+M_PI/2];
CLLocation *right = [topOfT newLocationAtDistance:meters
                              alongBearingradians:bearing-M_PI/2];
John Lemberger
  • 2,679
  • 26
  • 25