Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14




Topic: In the example rotation ...



  
Goto parent category
  
Create a new user account


   In the example rotation ...
 Poster : lintford
 Posts: 7
 Country : England
 City: Manchester

  
Posted by lintford on 28/05/2008 at 07:23:03
Hi Riemer,

Great tutorials, but I have a question about the rotation example that you provided.

You say we are to rotate the coordinates around the Z axis by 45 degrees.

But i don't understand in the matrix diagrams, how you go from :

cos(pi / 4)      =   2 squared over 2

and

cos(pi / 4)      =   2 squared over 2.


how do you get the 2 squared over 2 bit?

I would really appreciated it if you could provide some more information about this.

Thanks for your help and the tuts.

Adios
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 28/05/2008 at 15:53:27
Good question!

And luckily, the answer is quite simple. A sine (and a cosine) is just a number, always between -1 and 1. (You probably know Pi is also a number, 3.14)

so find a nice calculating maching, and type in "cos(pi/4)". Or just go to www.google.com, and type this in in the search field. You will get 0.707106781 as answer.

Now type in sqrt(2)/2. You will get the same number. I probably just have to omit the second step in the equation, and go immediately from cos(pi/4) to 0.7071.

Does this make any sense?
 Poster : Lintford
 Posts: 7
 Country : England
 City: Manchester

  
Posted by Lintford on 29/05/2008 at 05:03:12
Hi Riemer,

Thanks for the reply.

Yes, it does make sense (in that cos(pi/4) equals 0.7071 ).

but, if we took a different number, (not 45°) as the rotation degree, how would you work out the middle equation, obviously it wouldn't still be 2 squared over 2, did you just know this from expierence, or did you work it out some how? I still don't see any relationship between the two equations :s

Also, I made a mistake in my OP, I meant to ask, how or why is it that cos(pi/4) and sin(pi/4) both have the same values (0.7071); are they not different calculations - or is it just because theta is 45°? (did I use "theta" correctly :)

Thanks
Bye
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 29/05/2008 at 13:42:46
You're correct, it's a bad example. 45 degrees is the point where the sine and cosine have the same value (just like 45+180 degrees). That's why the result is known to be sqrt(2)/2.

More general, if you want to find the sine of angle x, do this:

sin(pi/180*x)

since Pi radians corresponds to 180 degrees. So in case of 20 degrees, you would get a sine value of 0.342 and a cosine value of 0.939.

And yes, you did use theta correctly ;)
If you have any suggestions on how I should update the chapter, let me know!

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)