Let's say you have vector $\vec{n} = (x_n, y_n, z_n)$. (I like to use $\vec{v}$ for vectors, but $\hat{v}$ for unit vectors.)
The first basis vector is parallel to $\vec{n}$, but length 1. Because we only use this one to construct the two interesting basis vectors, I'll number this 3:
$$\hat{e}_3 = (x_3, y_3, z_3) = \frac{\vec{n}}{\left\lVert\vec{n}\right\rVert}$$
We need an auxiliary vector which is not parallel to $\hat{e}_3$. If this auxiliary vector is also of unit length, the math in the following steps is simpler. There are many ways to construct one, but we need to be careful to not produce a vector too close to $\hat{e}_3$ (or its opposite!), or this approach will fail.
One interesting way to construct such $\hat{a}$ is to find out which two of the three components are largest in magnitude. Then, negate the largest in magnitude, and swap it with the second largest in magnitude. This yields an auxiliary vector at $70°$ to $90°$ angle to the basis vector, and keeps the vector length unchanged.
In pseudocode, this can be done as follows:
# Return an auxiliary vector, at 70 to 90 degree angle to
# the given vector, keeping length unchanged.
#
Function Auxiliary(x3, y3, z3):
xm = abs(x3)
ym = abs(y3)
zm = abs(z3)
If (xm >= ym), Then
# |x3| >= |y3|
If (ym >= zm), Then
# |x3| >= |y3| >= |z3|
xa = y3
ya = -x3
za = z3
Else,
If (xm >= zm), Then
# |x3| >= |z3| > |y3|
xa = z3
ya = y3
za = -x3
Else,
# |z3| > |x3| >= |y3|
xa = -z3
ya = y3
za = x3
End If
Else,
# |y| > |x|
If (xm >= zm), Then
# |y| > |x| >= |z|
xa = -y3
ya = x3
za = z3
Else,
If (ym >= zm), Then
# |y| >= |z| >= |x|, |y| > |x|
xa = x3
ya = z3
za = -y3
Else,
# |z| > |y| > |x|
xa = x3
ya = -z3
za = y3
End If
End If
Return (xa, ya, za)
End Function
It does not actually matter how you construct $\hat{a}$, as long as it is not parallel to (or have a very small angle with) $\hat{e}_3$. The above is nice -- although it is very dense to read and maintain, hopefully it only needs to be written and tested thoroughly once! -- because it yields an "almost" perpendicular vector, no matter what the input vector, with just three absolute values, three comparisons, and assignments.
In any case, with $\hat{a}$ not parallel to $\hat{e}_3$ we can now easily construct a vector $\vec{t}$ perpendicular to $\hat{e}_3$:
$$\vec{t} = \hat{a} - \hat{e}_3 \left ( \hat{a} \cdot \hat{e}_3 \right )$$
Because both vectors on the right side are of unit length, we don't need to divide by their lengths.
We have our first interesting basis vector if we normalize the perpendicular vector $\vec{t}$ to unit length:
$$\hat{e}_1 = \frac{\vec{t}}{\left\lVert\vec{t}\right\rVert}$$
The final basis vector is simply a cross product of the two other unit basis vectors. Because the two are of unit length and perpendicular, the result will be perpendicular to both, and also of unit length:
$$\hat{e}_2 = \hat{e}_3 \times \hat{e}_1$$
To generate $N$ points, $\vec{p}_1 \ldots \vec{p}_N$, at distance $r$ from $\vec{o}$, in a circle perpendicular to $\vec{n}$, use
$$\vec{p}_i = \vec{o} + r \hat{e}_1 \cos\left(\frac{2 \pi i}{N}\right) + r \hat{e}_2 \sin\left(\frac{2 \pi i}{N}\right)$$
with either $i = 1\ldots N$ or $i = 0 \ldots N-1$.
x = -0.068038 y = -0.0111010 z = 0.752
I want to find the vector (n1) which will be perpendicular to (N) and having length 0.0002 units.
Any idea how can I do that?
– Shahabaz Bagwan Aug 15 '16 at 06:15can you kindly provide me the values of b3 and b2 for this value.
– Shahabaz Bagwan Aug 17 '16 at 06:12