Sign in to follow this  
LittleFreak

Trig in Dirctx

Recommended Posts

Im trying to do trig calculations using pixils as the unit of lenght and directx's measurement for angle(cant remember the name of it)...thats where the problem comes in. Dont know anything about the messurement of angles in directx. Any help or site that can teach me about this would be greatly apperated. Thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
directx measures angles of vectors using cordinates that don't translate one to one into pixels. A good way to start thinking about these cordinates is to think of them as percentages so .5y would be half the screen, verticaly. Know depending on how you set up the camera this may or may not be true but that will not effect your angle measurements. Also pixel cordinates are all postive with the origin beeing in the upper left corner of the screen, directx cords are bith positive and negative like you learn in geomatry with the orgin beeing in the center.

the fuction Vector2.Angle is most likely where you want to start it accepts 2 vectors(lines) and gives you the angle.

To give you a idea of how this works cosider the following

//C# code
Vector2.Angle(new Vector2(0,1),new Vector2(1,1))

this would be a 45 degree angle.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I made a mistake that angle function does not exist I think I must have added to my codebase.

http://www.vb-helper.com/howto_find_angles.html

this will explain what you need to know about dot products and finding angles.

if you want to know the angle between your vector and the origin you can you this simpler approcach

angle = Atan(hieght/length)

the hieght will always = the y of a point and DX provides the length of a vector(Vector2.length) the atan fuction is located at Math.Atan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this