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 ?

  • $\begingroup$ does "perpendicular" entail concurrency? $\endgroup$ – 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$$

  • $\begingroup$ Thanks. Can you show some code in C++ ? How would I convert points for examples into parametric lines ? $\endgroup$ – Ahmed Saleh Dec 23 '17 at 19:59
  • $\begingroup$ Coding questions are not usually asked here. You could try at stackoverflow.com $\endgroup$ – Ethan Bolker Dec 23 '17 at 20:07
  • 1
    $\begingroup$ @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). $\endgroup$ – gimusi Dec 23 '17 at 20:12
  • $\begingroup$ how to define t ? $\endgroup$ – Ahmed Saleh Dec 23 '17 at 20:13
  • $\begingroup$ $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 $\endgroup$ – gimusi Dec 23 '17 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.