Help calculating a point in 2d space on a rotating right angle triangle

Dec 2015
4
0
Phoenix


I am trying to solve for a point on a triangle that rotates around a fixed point. For ease of calculation this point is at X: 0 Y: 0


The length and width of the triangle are always fixed, the only thing that changes is the rotation angle. How can I solve for X: ??? and Y: ??? taking into account the rotation angle?

I am trying to place a 2d rendered object in Java so I need to break the formula down to it's base elements so I can put it into code and have the formula spit out X and Y coordinates

The known variables are all listed in the pictures. The angle of the triangle, the length & width. Anything else that is needed to find the ??? must be calculated first I guess.

Please don't just link wiki pages. I have read them. I don't understand them. Hence why I am asking for help walking through the solution.

Thank you!
 
Jun 2008
1,389
513
Illinois
Start by determining the angle of the hypotenuse of the original triangle:

\(\displaystyle \theta = \tan^{-1} \frac W L\)

and the length of the hypotenuse of the triangle, which I will call C:

\(\displaystyle C = \sqrt{L^2 + W^2}\)

The initial point (x,y) is then:

\(\displaystyle (x_1,y_1) = (C \cos \theta, C \sin \theta) \)

Note: \(\displaystyle (x_1, y_1)\) also equals \(\displaystyle (W,L)\)

Now let's assume you rotate the triangle by the angle alpha. The new (x,y) coordinates are:

\(\displaystyle (x_2, y_2) = (C \cos (\theta + \alpha), C \sin (\therta + \alpha))\)
 
Last edited:

skeeter

MHF Helper
Jun 2008
16,217
6,765
North Texas
$\displaystyle \left[\begin{array}{cc}x'\\y'\end{array}\right] = \left[\begin{array}{cc}\cos(35)&-\sin(35)\\\sin(35)&\cos(35)\end{array}\right] \cdot \left[\begin{array}{cc}3\\-5\end{array}\right]$

$x' = 3\cos(35) + 5\sin(35) \approx 5.33$

$y' = 3\sin(35) - 5\cos(35) \approx -2.38$
 
Feb 2015
2,255
510
Ottawa Ontario
I'm a bit confused...

1st, why not (as your example) use a 3-4-5 right triangle (hypotenuse = 5)
instead of the 3-5-SQRT(34) that you used?
(not important...just seems strange)

2nd, why bring in a right triangle at all?
Isn't your problem simply a given straight line (who cares if it's an hypotenuse!)
with one end at (0,0) moving such that a circle with radius = line length is formed?
And you want to calculate the coordinates of other end of line, given an angle?

Like with Skeeter's solution, 5.33^2 + 2.38^2 = ~SQRT(34).

Or am I just too dumb to understand "rotation angle"?
 
Dec 2015
4
0
Phoenix
DennisB

I have an L shaped figure in my program that rotates around the top of the L. I need to place another object at the end of the horizontal part of the L in 2d space

So it is a right angle triangle. You just don't see the hypotenuse.

Did that answer your question?
 
Last edited:
Feb 2015
2,255
510
Ottawa Ontario
Yes, I understand that. I follow everything except:
Skeeter's 35 degrees...where, oh where, praytell,
does that come from?
I'll probably kick myself when you tell me !

Btw, I have a Phoenix Suns jacket with Steve Nash on the back...so be nice :)
 
Dec 2015
4
0
Phoenix
The 35 degrees comes from teh second image. I need the point at the end of the L if it is rotated 35 degrees. it is a bit small font

 
Feb 2015
2,255
510
Ottawa Ontario
OK; gotcha! Had to get my binoculars :)
 
Last edited:
Jun 2008
1,389
513
Illinois
I see I made two errors in my original post. First I used a coordinate stystem where positive y is down, whereas down should be negative y, and secondly I confused sines and cosines (doh!). Hence this part of my post:

The initial point (x,y) is then:

\(\displaystyle (x_1,y_1) = (C \cos \theta, C \sin \theta) \)
should be:

\(\displaystyle (x_1,y_1) = (C \sin \theta, -C \cos \theta) \)

And this part:

The new (x,y) coordinates are:

\(\displaystyle (x_2, y_2) = (C \cos (\theta + \alpha), C \sin (\therta + \alpha))\)
should be:

\(\displaystyle (x_2, y_2) = (C \sin (\theta + \alpha), -C \cos(\therta + \alpha))\)

Sorry for any confusion. With these changes and using alpha = 35 degrees I get \(\displaystyle (x_2,y_2) = (5.325,-2.375)\). By the way, it appears that the figure was actually drawn with alpha = 30 degrees, not 35 degrees.
 
Last edited:
  • Like
Reactions: 1 person
Dec 2015
4
0
Phoenix
Yeah I went back and looked at my photoshop, it was 30 :)
Actualy it was -30 (>.<) but I got the formula and I can confirm it works in the program.
Thank you all so much.