How to find the sign of directional distance?

I have 2 points, P and Q, on a directional line AB in three-dimensional space. They can be anywhere on the line, that is, not necessarily between A and B.

Pythagoras gives you the distance, obviously, but how can I calculate the sign of the directional distance from P to Q?

+3
source share
5 answers

Take dot product from AB and PQ . Positive => the same direction, negative => the opposite direction.

+5
source

Q-P B-A AB PQ, .

sign (signed_distance) = (PQ AB)

[x, y, z] · [p, q, r] = x✕p + y✕q + z✕r

AB, (sqrt ),

N= AB/| AB |

AB

signed_distance = PQ N

, sqrt , A B .

+4

(x, y, z) , , A- > B. , B-A (xB-xA, yB-yA, zB-zA). Q-P. x ( y z), B-A, AB, .

1 x, y z, AB x, y z, .

0

, . , , , , .

(p1, p2, p3) (q1, q2, q3), , P Q :

V = (q1-p1) * + (q2 - p2) * j + (q3 - p3) * k

where (i, j, k) are vectors of magnitude 1 in the x, y, and z directions, respectively.

The value (e.g. distance) from P to Q is the square root of the sum of the squared components.

0
source

The points are on the line AB, and you want the distance from P to Q.

The line is from A to B, so you can define alpha to:

Point = alpha (B-A) + A

You will find alpha P and Q, and if alpha P is greater than the Q sign, the sign is negative.

0
source

Source: https://habr.com/ru/post/1703275/


All Articles