I'm trying to derive a formula to extract vector u
.
I'm given some initial data:
- Plane
F
with the method to extract its normaln = F->normal()
. - vector
c
that does not lie within the planeF
and passes through some pointE
that also does not lie within the planeF
.
And some constrains to use:
- The desired vector
u
is perpendicular to the vectorc
. - Vector
u
is also perpendicular to some vectorr
which is not given. The vectorr
is parallel to the planeF
and also perpendicular to the vectorc
. Therefore, we can say the vectorsc
,r
andu
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?
r = c ^ n
– coproc