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
To solve this problem I'll do the following :
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 :
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'.
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:
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.
r = P1-P0
a = Dot(r,x)/Dot(x,x)
P2 = P1-a*x
b=Magnitude(P2-P0)
y=(P2-P0)/b
Done!
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
.