views:

40

answers:

1

I have three known 3-Dimensional points: A, B, and C.

Addtionally, I have a fourth point, X.

X lies on vector AB such that vector CX is perpendicular to vector AB. So AB · CX = 0

How do I find the unit vector of CX?


The use-case here is that I am constructing a (translated) rotational matrix, where the origin is A, the z-axis passes through B, the xz-plane passes thtough C, and the axes are orthogonal

I also have a vector object that provides dot and cross product functions at my disposal.

+2  A: 

Let

U = (B-A)/||(B-A)

be a unit vector along the line from A to B, where ||X|| denotes the length of vector X. Now we can parameterize the entire line by

A + tU

and we want

((A + tU) - C)*U = 0

so that

A*U - C*U + t = 0
t = C*U - A*U

so we've solved for t, and now we let

V = (A+tU - C)/||A+tU - C||

and we have our unit vector along the line, U, and one orthogonal to it, V.

Rex Kerr
Does `A*U` denote the dot or cross product?
Eric
So `V = (A + (C·U - A·U) * U - C)/||(A + (C·U - A·U) * U - C)||`?
Eric
@Eric - `*` is the dot product, and yes, you've expanded it correctly.
Rex Kerr
Which is equivalent to normalizing `((A - C) + (C - A)·U * U)`?
Eric
@Eric - That looks right.
Rex Kerr