# Getting lengh of vector with slope. Trigo problem

This topic is 4174 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there! How are you? I have problem. I have object Tank and tank have Canon :) Canon can be with different slope: I added a picture to show what i mean Now i'll explain what i have and what i need to find. I have and object in my case tank and his axises. A point coordinates are x=0 y=0 I also know that alfa angle can be between 0<=a<=2Pi The red line is canon of the tank, Now i need to calculate B point coordinates according to the current angle. Lets say alfa = 90grad = PI/2rad => B coordinates are x=0 y=y1 If alfa = 180grad = PIrad => b x=-x1 y=0 I need system of equations for x and y separately that will dependance on alfa angle. I hope you got it and will be able to help me. Thanks!

##### Share on other sites
The sine function (which usually takes radians) will give you a value that is equal to if you had taken the length of the side opposite from the corner whose angle measurement you used, and divided it by the length of the hypotenuse, the side that is opposite from the 90° angle. Side-opposite over hypotenuse, in short. To get just the length of the opposite side, just multiply the result of the sine function by the hypotenuse length. That will cancel out the hypotenuse component from the sine function, leaving the side-opposite length. In your case, side-opposite corresponds to the y axis.

Similarly, cosine returns side-adjacent over hypotenuse. Cosine multiplied by hypotenuse will therefore give you the side-adjacent length, or x in this case.

                            ---+                        ----   |       Hypotenuse   ----       |                ----           | Opposite            ----               |   Side        ---- \ <-- Angle     __|    ----     |              |  |+------------------------------+ <-- Right Angle        Adjacent Side

So you'll need to know the length of your turret barrel. Given that (as barrel_length), and the angle in radians (as theta, the most common Greek letter for angles), x and y are therefore:

x = cos(theta) * barrel_length;
y = sin(theta) * barrel_length;

##### Share on other sites
Oh I made a mistake in calculation :X
Thanks a lot!

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 46
• ### Forum Statistics

• Total Topics
632635
• Total Posts
3007569
• ### Who's Online (See full list)

There are no registered users currently online

×