Reputation: 357
I am not sure if a question like this was asked before but i searched and didn't found what i am looking for.
I know how to determine if a point is to the left or right of a 2D line. but suppose we have a vector in 3D. of course a 3D vector passes through infinite planes, but suppose we chose one plane of them in which we are interested, and we have a specific point on this plane which we want to know if it lies to the left or right or on our vector (with respect to the chosen plane). how to do this ?
Upvotes: 0
Views: 1997
Reputation: 80232
You should explicitly define orientation of that plane - for example, define main (forward) normal N
- like OZ
axis is normal for OXY
plane.
If you have A,B,C triangle and claim that it is oriented counterclockwise, you can calculate forward plane normal as N = AB x BC
For points A, B, D
in given plane calculate mixed product (vector product of AB
and AD
, then scalar product of result and N
)
mp = (AB x AD) . dot. N
Sign of this value is positive, if vectors AB, AD, N
form right-handed
triplet and D lies left to AB direction
Upvotes: 1
Reputation: 4718
An intuitive solution is to define a coordinate system for the plane as follows. Let's normalize the 3d vector in your question and call the resulting unit vector v
, and let x
be a point on your plane, whose unit normal we will denote as n
. You can now chose a coordinate system centered at x
, that is made by the three 3*1
unit vectors v
, n
and b=v.crossProduct(n)
.
The idea is that if you express a point in this coordinate system, then if its b
coordinate is negative, you can says that it is, say, on the left. So, if its b
coordinate is positive, it will be on the right.
Obviously, if you have a point q
expressed in this coordinates system, you can write its expression q_w
in world coordinates using
q_w=R*q+x
where the rotation matrix R is the matrix whose columns are the unit axes of the plane coordinate system:
R=[v n b]
So, if you have a point Q
in world coordinates, using the inverse of the relation above, you compute transpose(R)*(Q-x)
, and look at whether the b
coordinate is positive or negative.
Upvotes: 0