Search code examples
3dspacepoints

3D : Given 2 points (P0, P1), find the third point (P2) where DotProduct(P0P2, P1P2) == 0


Sorry for my bad english.

Do you know the best (in performance) algorithm to find the solution of the problem in the Title. As a reminder, the problem is :
Given 2 points (P0, P1), find the third point (P2) where DotProduct(P0P2, P1P2) == 0 enter image description here

To solve this problem I'll do the following :

  • The distance P0P1 (dist(P0, P1)) is known. So i retrieve two equations with pythagore : dist(P0, P2)² + dist(P1, P2)² = dist(P0, P1)²
  • I retrieve two other equations with dot product : DotProduct(P0P2, P1P2) = 0
  • Finally, I solve the system with 4 equations and 3 variables

But I think there is a more efficient solution.

Can you help me ?

Thank you :)

PS : I am working in Space (3D)

Edit : As ja72 said, I forgot to add constraints... So Here is the problem in its entirety : enter image description here
I have P0 and P0' which define the local X axis of an object (P0 is the center of the object).
I also have P1 which I must use to find P2 so the line P0P2 defines the local Y axis of this object.
P1 is orthogonal to P0P0'.


Solution

  • As I explained in the comments, there needs to be more constraints in order to define a single unique point. In fact, you need 2 more constraints.

    The problem is shown below:

    pic

    Take any plane which contains P0 and P1. Draw a circle with P0 and P1 as diameter points. Any point along the circle is going to have DOT(P0-P2,P0-P1)==0 by default. See Thale's Theorem.

    Edit 1

    The problem is defined now as decomposing the relative position of P1 to P0 along the x axis and finding the perpendicular y such that

    P1 = P0 + a*x + b*y
    

    where a and b are distances defined below. Each P1, P0, x and y is a 3D vector with (x,y,z) values.

    1. Define the relative vector r = P1-P0
    2. Find the distance a = Dot(r,x)/Dot(x,x)
    3. Find the point P2 = P1-a*x
    4. Find the distance b=Magnitude(P2-P0)
    5. Find the unit vector y=(P2-P0)/b

    Done!

    pic2

    NOTE: x does not need to be a unit vector, but it helps in order for the value a to correpsond to the actual projected distance between P0 and P1.