I have two rectangles as in the picture below which can be located anywhere relative to each other.
I have the coordinates of the rectangle centers (c1 and c2) and the lenght/height of both rectangles.

How can I find the coordinates of points p1 and p2 - where the line between the centers crosses the edges?

enter image description here

  • $\begingroup$ Where is the picture? $\endgroup$ – sinbadh Jan 17 '16 at 7:18
  • $\begingroup$ trying again... $\endgroup$ – LK__ Jan 17 '16 at 9:18

If you know the two center points' coordinates, you can come up with an equation for the line between them. Then, say for P2, you can plug in $C2-\frac{L2}{2}$ into your equation for the line for the $x$ value and solve for $y$.

Then solve for P1 similarly.


Say the rectangle has dimensions $ (L,h) $

Equation of inclined line

$ \dfrac{y}{x}= \dfrac{c_2}{c1} \tag{1} $

Equation of vertical lines

$ x= L/2 \tag{11}$

$ x= -L/2 \tag{12}$

$ x= c_1+L/2 \tag{13}$

$ x= c_1-L/2 \tag{14}$

Equation of horizontal lines

$ y= h/2 \tag{21}$

$ y= -h/2 \tag{22}$

$ y= c_2+h/2 \tag{23}$

$ y= c_2-L/2 \tag{24}$

Now choosing four out of the eight lines, find points of intersection ( choose which line you want to cut which line) with the inclined line.


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.