Home > Blockchain >  How to draw line pass through point and center of rectangle?
How to draw line pass through point and center of rectangle?

Time:08-24

There is a point A and quadrilateral with Longitude and latitude, I calculate the center of quadrilateral C, then I want to draw a line pass through A to C and extend that line to -20 latitude B, how can I calculate the coordinate of point B?enter image description here

CodePudding user response:

  1. Define quadrilateral for a sphere.
  2. Find C, the center. Or at least approximate it. For example avg lat and avg lng might be "close enough".
  3. Convert A and C to [x,y,z] assuming center of earth is [0,0,0].
  4. You now have 3 3D points. This defines a circle on the plane that goes through all 3.
  5. Find the plane where B is. Note that this latter plane does not go through [0,0,0]; instead [0,0,z] where z is some simple trig based on -20 deg latitude.
  6. Find the line that intersects those two planes.
  7. Find, on the line, the x,y for the above z.
  8. Convert [x,y,z] to polar to get longitude.

(Sorry, I don't have the energy or incentive to fill in the details.)

(There could be a simpler algorithm, but I doubt if it would have many fewer steps.)

  • Related