Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a line with coordinates (a1, b1) and (b2, b2). I want to calculate the (x1, y1) and (x2, y2) as shown in image below such that the line will form a rectangle. Given, I know the height of the rectangle, how what is the easiest way to calculate (x1, y1) and (x2, y2)?

enter image description here

share|improve this question
1  
The slope of your given segment is $\frac{b_2-b_1}{a_2-a_1}$; take the negative reciprocal of that for the perpendicular, and then you should be able to reckon how to get the two other points needed... –  J. M. Dec 22 '11 at 11:28

2 Answers 2

up vote 2 down vote accepted

As J.M. says, the line from $(a1,b1)$ to $(x1,y1)$ has slope $\sigma = -\frac{a2-a1}{b2-b1}$. So points on the line have the form $$(x,y) = (a1+t, b1+\sigma t)$$You have to choose $t$ so that $(x1,y1)$ is at a distance $h$ from $(a1,b1)$. The distance is $t\sqrt{1+\sigma^2}$, so put $$t=h/\sqrt{1+\sigma^2}$$

The same $t$ serves to calculate $(x2,y2)$.

share|improve this answer
    
Excellent and easy. Thanks @TonyK! –  Ramesh Soni Dec 22 '11 at 13:04

Let's denote Height as $h$. You should solve following system of equations :

$\begin{cases} h=\sqrt{(x_1-a_1)^2+(y_1-b_1)^2} \\ h=\sqrt{(x_2-a_2)^2+(y_2-b_2)^2} \\ \sqrt {(b_2-b_1)^2+(a_2-a_1)^2}=\sqrt{(y_2-y_1)^2+(x_2-x_1)^2} \\ \frac{y_2-y_1}{x_2-x_1}=\frac{b_2-b_1}{a_2-a_1} \end{cases}$

share|improve this answer
    
There are easier ways :-) –  TonyK Dec 22 '11 at 12:18
    
@TonyK,It's good to "see" you...you are my favorite critic :-) –  pedja Dec 22 '11 at 12:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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