Note that there are some explanatory texts on larger screens.

plurals
  1. POFind nearest position from a fixed position to a line joined by two GPS positions
    primarykey
    data
    text
    <p>I want to find the nearest position from a fixed position to a line joined by two GPS positions. I have tried to illustrate it with the means of a diagram. All positions are in GPS coordinates. I want to find the ´shortest diatance from the position P to the line joined from position A and position B,i.e., the line from P makes a 90 degree on line joining A and B. It would be really great if you know of an existing implementation for this or an algorithm for the same. Many Thanks. <img src="https://i.stack.imgur.com/YazW1.png" alt="enter image description here"></p> <p>The way i was told to calculate is: first convert the GPS positions into cartesian coordinates. For the conversion , it uses a reference position (Q_Ref_longitude, Q_Ref_latitude).</p> <pre><code>x=(longitude-reflong)*π/180*r_e, r_e radius of earth y=artanh(sin⁡(latitude)) Therefore the reference point has the Cartesian coordinates (0,artanh(sin⁡(reflat))). conv(refp)=(0,artanh(sin⁡(reflat))) All positions A,B, P are converted to (x,y) coordinate system Calculation of the intercept point with reference Cartesian coordinates (x,y)∈R^2: In the following context (vp) ⃗∈R^2 is the position vector of the P in reference Cartesian coordinates. &lt;a ⃗,b ⃗&gt; is the dot product of two vectors a ⃗ and b ⃗. (op2) ⃗ refers to position A (op1) ⃗ refers to position B (vp) ⃗ refers to position P (op1) ⃗,(op2) ⃗,(vp) ⃗∈R^2 intPoint=[(&lt;((op2)-(op1)),((vp)-(op1))&gt;)/(&lt;((op2)-(op1)),((op2)-(op1))&gt;)]*((op2)-(op1))+(op1) The intercept point has to be transformed back into GPS coordinates with the following inverse formula: Iconv:R^2→[-180°,180°]×[-90°,90] longitude=x+reflong latitude=arcsin⁡(tanh⁡(y)) </code></pre> <p>Does someone know about this way? I tried to do this way but it gives negative values.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload