I have two parallel line segments, say AB, CD. If I project the end points onto a common third parallel line, then I want to know the portion of overlap made by above 2 lines. I think I should use scalar of lines but, I am confused to figure out how to calculate this (I have 4 scalars).. I feel, when the line segments orient in opposite directions, then scalar might be +,-. then the case of so difficult for me to understand.

If anyone can, help me to figure out a procedure to do this.

thanks in advance.


I assume that you are talking about line segments on a 2D plane and "projection" means "orthogonal projection". That is, the projection of $A$ on a line is the foot of perpendicular from $A$ to that line, and so on and so forth.

Let $A=(a_1,a_2),\ B=(b_1,b_2),\ C=(c_1,c_2)$ and $D=(d_1,d_2)$. Let the third line passes through some two points $P=(p_1,p_2)$ and $Q=(q_1,q_2)$. So the vector $$ \vec{u}=(u_1,u_2)=\frac{\vec{PQ}}{\|\vec{PQ}\|}= \frac{1}{\sqrt{(q_1-p_1)^2+(q_2-p_2)^2}}(q_1-p_1,\,q_2-p_2). $$ has length $1$ and it is parallel to the third line. Now, if you set $P=(p_1,p_2)$ as the origin, and let the half of the third line that extends from $P$ and points to the direction of $\vec{u}$ as the "positive $u$-axis", and the other half as the "negative $u$-axis", then the "$u$-coordinate" of the projection of $A$ on the third line is given by $\vec{PA}\cdot\vec{u}$, i.e. $$(a_1-p_1)u_1+(a_2-p_2)u_2.$$ Replace $(a_1,a_2)$ in last expression by $(b_1,b_2), (c_1,c_2)$ or $(d_1,d_2)$, you get the $u$-coordinates of $B,C$ or $D$. You can now do your computation as if $A,B,C,D$ all lie on the same $u$-axis, with their corresponding $u$-coordinates.

  • $\begingroup$ thank you very very much. but it is my mistake, i forgot to tell that I am having 3D lines. then, how would it be? same? $\endgroup$ – gnp Nov 27 '12 at 20:46
  • $\begingroup$ It depends on your definition of "projection". If you are talking about foot of perpendicular, then the analogous procedure will still give you the $u$-coordinates. However, since each point is now specified by 3 coordinates (x,y,z) instead of 2 (x and y), you must take care of the extra one. For instance, the dot product $\vec{PA}\cdot\vec{u}$ would become something like $(a_1-p_1)u_1+(a_2-p_2)u_2+(a_3-p_3)u_3$, etc.. Also, if the direction of your "projection" is not perpendicular to the third line, the story will be different. $\endgroup$ – user1551 Nov 27 '12 at 21:21

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.