Jump to content
• Advertisement

# Trig in Dirctx

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

If you intended to correct an error in the post then please contact us.

## 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

##### Share on other sites
Advertisement
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

##### Share on other sites
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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Now

• 18
• 29
• 11
• 21
• 16
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!