Reputation: 1733
I'm trying to derive a formula to extract vector u
.
I'm given some initial data:
F
with the method to extract its normal n = F->normal()
.c
that does not lie within the plane F
and passes through some point E
that also does not lie within the plane F
.And some constrains to use:
u
is perpendicular to the vector c
. u
is also perpendicular to some vector r
which is not given. The vector r
is parallel to the plane F
and also perpendicular to the vector c
. Therefore, we can say the vectors c
, r
and u
are orthogonal.Let's denote *
as dot product, and ^
operator is cross product between two 3d vectors.
The calculation of the vector u
is easy by using cross product: vec3 u = c^r
. So, my whole task is narrowed down to how to find the vector r
which is parallel to a given plane F
and at the same time perpendicular to the given vector c
.
Because we know that r
is parallel to F
, we can use plane's normal and dot product: n*r = 0
. Since r
is unknown, an infinite number of lines can satisfy the aforementioned equation. So, we can also use the condition that r
is perpendicular to c
: r*c = 0
.
To summarize, there are two dot-product equations that should help us to find the vector r
:
r*c = 0;
r*n = 0;
However, I am having hard time trying to figure out how to obtain the vector r
coordinates provided the two equations, in algorithmic way. Assuming r = (x, y, z)
and we want to find x
, y
and z
; it does not seem possible from only two equations:
x*c.x + y*c.y + z*c.z = 0;
x*n.x + y*n.y + z*n.z = 0;
I feel like I'm missing something, e.g., I need a third constrain. Is there anything else needed to extract x
, y
and z
? Or do I have a flaw in my logic?
Upvotes: 1
Views: 2555
Reputation: 33509
You can find the vector r by computing the cross product of n and c.
This will be automatically satisfy r.c=r.n=0
You are right that your two equations will have multiple solutions. The other solutions are given by any scalar multiple of r.
Upvotes: 2