views:

17

answers:

1

Hi, If you would look at this diagram link text, I need to find angle A by only knowing the length of all sides of a right triangle.

I don't know trig and need some help.

A: 

Hello... There are actually 2 questions in your post.

How to make a sprite point at the mouse. XNA C#:

You will have to calculate the direction between the position of the sprite and the position of the mouse. This can be done using trigonometry functions. In this case: Arctangens2

So let's use the math library:

MouseState mouseState = Mouse.GetState();
Math.Atan2((double)mouseState.Y - sprite.Y, (double)mouseState.X - sprite.X); //this will return the angle(in radians) from sprite to mouse.

In your trigonometry example you will see that those values actually are:

Math.Atan2(BC, AC);

or

Math.Atan2(Ydiff, Xdiff);

I hope this helps =D

Cheers,

TomHashNL

TomHashNL