I have a vector $v_1$ (suppose $v_1= \langle a_1, b_1,c_1\rangle$) and this $v_1$ passes through the point $(x_1,y_1,z_1)$. Now I need a second vector, $v_2$ which is perpendicular to $v_1$. Suppose that $v_2$ is passing through the second point $(x_2,y_2,z_2)$. However, my final goal is to find the intersection point of above two lines. So, could you help me to find the vector which is perpendicular to another given vector? Please anyone help me.
[Math] compute a vector which is perpendicular to another given vector (all are in 3D)
geometryvector analysis
Related Solutions
Your problem for $z=0$ reduces to the polar coordinate problem already answered here. $$|\vec v_3|^2=(\vec v_2-\vec v_1)\cdot(\vec v_2-\vec v_1)=|\vec v_1|^2+|\vec v_2|^2-2\vec v_2\cdot \vec v_1$$ Now using cylindrical coordinates, $|\vec v_i|^2=r_i^2+z_i^2$ and $\vec v_2\cdot \vec v_1=r_1r_2\cos(\theta_2-\theta_1)+z_1z_2$. Then the final answer will be $$|\vec v_3|^2=r_1^2+r_2^2-2r_1r_2\cos(\theta_2-\theta_1)+(z_2-z_1)^2$$
It looks like OP is looking for an algorithm to find a perpendicular vector.
Let $\mathbf{p}_1 = (x, y, z)$ be the original unit vector, $x^2 + y^2 + z^2 = 1$. I shall use notation $$\mathbf{p}_1 = (x, y, z) = \left[\begin{matrix}x\\y\\z\\ \end{matrix}\right]$$ where the parenthesised form $(x, y, z)$ is just shorthand for the proper vector/matrix form.
Construct two helper vectors by rotating $\mathbf{p}$ 90° around two different axes (the axes being perpendicular to each other), say around the $z$ axis and the $y$ axis, $$\begin{aligned} \mathbf{q}_1 &= (y ,\, -x ,\, z) \\ \mathbf{q}_2 &= (z ,\, y ,\, -x) \\ \end{aligned}$$ and calculate their vector cross products wrt. the original vector: $$\begin{aligned} \mathbf{d}_1 = \mathbf{p} \times \mathbf{q}_1 &= ( y z + x z ,\, y z - x z ,\, - y^2 - x^2 ) \\ \mathbf{d}_2 = \mathbf{p} \times \mathbf{q}_2 &= ( - y z - x y ,\, z^2 + x^2 ,\, x y - y z ) \\ \end{aligned}$$ One of these may be a zero vector (or very small), depending on how close the original $\mathbf{p}$ was to the respective rotation axis, but if nonzero, they are perpendicular to the original vector. So, pick the larger one in magnitude: $$\mathbf{p}_2 = \begin{cases} \displaystyle \frac{\mathbf{d}_1}{\left\lVert \mathbf{d}_1 \right\rVert}, & \left\lVert \mathbf{d}_1 \right\rVert \ge \left\lVert \mathbf{d}_2 \right\rVert \\ \displaystyle \frac{\mathbf{d}_2}{\left\lVert \mathbf{d}_2 \right\rVert}, & \left\lVert \mathbf{d}_1 \right\rVert \lt \left\lVert \mathbf{d}_2 \right\rVert \\ \end{cases}$$
Best Answer
Ok, so your line $\ell$ has parametric equations $$ x=x_1+at,\qquad y=y_1+bt,\qquad z=z_1+ct. $$ If $Q=(x_2,y_2,z_2)$ is a point, the equation of the plane $\pi$ perpendicular to $\ell$ and passing through $Q$ has equation $$ a(x-x_2)+b(y-y_2)+c(z-z_2)=0. $$ Now just plug the former equations into the latter and solve for $t$.