# Finding perpendicular lines in 3D

I'm trying to measure a Cube using computer vision. So I have a lot of lines in 3D space, I would like to find if three lines are perpendicular to each other in C++. Is that possible to find a fast method of doing that ?

• does "perpendicular" entail concurrency? – Lord Shark the Unknown Dec 23 '17 at 19:52

consider the parametric equations for the lines:

$$P_1+\vec v_1t$$$$P_2+\vec v_2t$$$$P_3+\vec v_3t$$

and then impose that

$$\vec v_1\cdot \vec v_2=\vec v_2\cdot \vec v_3=\vec v_3\cdot \vec v_1=0$$

• Thanks. Can you show some code in C++ ? How would I convert points for examples into parametric lines ? – Ahmed Saleh Dec 23 '17 at 19:59
• Coding questions are not usually asked here. You could try at stackoverflow.com – Ethan Bolker Dec 23 '17 at 20:07
• @AhmedSaleh I'm not skilled in C++. Find parametric lines is simple once you have two points P and Q it is: P+(Q-P)t. For example: P(1,2,3) and Q(3,2,2) thus line PQ: (1,2,3)+t(2,0,-1) therefore the vector v is Q-P (2,0,-1). – gimusi Dec 23 '17 at 20:12
• how to define t ? – Ahmed Saleh Dec 23 '17 at 20:13
• $t$ is a parameter $\in \mathbb{R}$, for each value you obtain a point on the line, EG for t=0 P and for t=1 Q, but for your needing v is the important object for you – gimusi Dec 23 '17 at 20:15