[FIXED] Get position of end of angle?

Hey guys, I am once again here because I am stumped on something. In my game, I want to calculate the position of the end of the arm, if you can imagine this, I have the arm rotation angle (from the center of the body), and I have the distance of the arm. Can someone point me in the right direction or give me some pseudo code.

you need to use some trigonometry for this. it will probably involve using cos and sin. you have the length of the arm, which is the hypotenuse , and you have 2 angles. 1 being the arm angle, and the other being the 90 degrees of the triangle you are using for calculation. you can use these knows values to work out the other 2 sides of the triangle, these other 2 sides will be what you add to the x and y position of the body to get the position of the arm.

thats probably not explained well, but thats what you use to work with angles like that in 2d.

or just have a quick read of this 8)
instead of moving the object *speed, move it *armLength

simply if I have the origin 0,0 and angle 50 to calculate the endx endy position at a specific radius I use x = radius * sin(angle) y = radius * cos(angle) fairly simple to perform and to explain it if you think of combining the cosine and sine graphics you end up with a circle.

int x = Math.sin(armAngle);
int y = Math.cos(armAngle);

All of the previous answers tended to be right :smiley:

int armX = armSourceX + armLength * Math.cos(angle);
int armY = armSourceY + armLength * Math.sin(angle);

lrn2trig

Do you mean this thread?

Dude this is simple, simple stuff. Everyone here has posted correct information. Agro has the most complete answer at this point, but if it still not enough:

As you might notice, this is basically Agro’s answer.

Now you also see why it is indeed a radius. (A radius is a distance)

A few things, you should be able to apply the previous formulas without any problems (apart from converting to radians) , I said radius because the function you are using is a circlular function and it would generally be the radius.

I know the topic title says that you’ve already fixed your issue, but if you want my take on this issue: