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.

When drawing an angle line (45 degrees) in a rectangle from a general point p(x,y) that located on the right or the top line of the rectangle. How can I find the intersection point p2 of this line with the rectangle?

In other words, I want to write the target point, p2, with my current information: x, y, w, h. (This variables are described in the picture below).

The point (0,0) is in the top-right corner.

alt text

share|improve this question
2  
Could you rephrase your question? I can't tell what is being asked. Does the line passing through ??? and (x,y) have slope 1? –  Larry Wang Jul 28 '10 at 0:55
    
The line is going from p (a point in the right or top line) to p2 a point in the left or bottom line. p coordinates are x and y. How can I represent p2 by x,y,w,h? –  stacker Jul 28 '10 at 1:02

3 Answers 3

Alright, I'm not 100% sure I'm understanding this correctly. You say that p can be located on the right or top line and that p2 can be located on the bottom or left line. Do you mean the rectangle can be rotated? If that's the case, the question should say that p can be on the right or bottom line of the rectangle. Also, are you looking for two separate answers or one that works both when p2 is on the bottom and on the left?

If you do mean that the rectangle can be rotated, and want two different answers, it's pretty simple. First I'll deal with when p2 is on the bottom and p is on the right.

Since p2 is on the bottom line we know the y-coordinate is h, according to the diagram. We also know that p is (0,y). Because of the 45 degree angle, we know that the distance between p's y-coordinate and the lower right corner is the same as the distance between the lower right corner and p2's x-coordinate, which in this case is p2's x-coordinate. Therefore, the coordinates of p2 are (h-y, h).

If p2 is on the left and p is on the bottom, it's very similar. Since p2 is on the left, it's x-coordinate is h. Because p is on the x-axis, it's (x,0). Because of the 45 degree angle, the distance between the lower left corner and p is the same as the distance between the lower left corner and p2, which this time gives us p2's y-coordinate. Therefore the coordinates of p2 are (h,h-x).

Hopefully I understood your intentions correctly. If not, I hope you can use my misunderstandings to further improve your question.

share|improve this answer
    
The rectangle cannot be rotated. The p is a general point, that his x and y coordinates, are on the right or the top line. –  stacker Jul 28 '10 at 17:20

If it is just $45$ degrees, then the answer is not very difficult. Center a coordinate system at the bottom left hand corner of the rectangle. Hence the coordinates of the (???) point are $(q,0)$ for some $q<w$.

Note that the because theta is $45$ degrees, $y=w-q$ (Isosceles right triangle). Hence $q=w-y$, and our point is simply $(w-y, 0)\dots$

share|improve this answer
    
I edited the question to define (0,0). I don't know why you're assume that p2 always on the bottom line. It can be also on the left line. –  stacker Jul 28 '10 at 2:53

Doesn't this depend on the slope of the segment that begins at $P=(x,y)$? Perhaps assuming some sort of proportionality we can solve this problem. Please provide more information. ${}$

share|improve this answer
    
The slope is 45 degrees. But we can be more general, and call is theta θ. –  stacker Jul 28 '10 at 1:09

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.