Sine & Cosine

hog

Senior Contributor
Joined
Mar 17, 2003
Messages
984
Location
UK
OK I posted here for max coverage as maybe not everyone in the know would call in on the graphics forum.

I know nothing of Sine and Cosine apart from what I'm reading in a book now:(

This is a line of code from my book;

Visual Basic:
objDirect3DDevice.Transform.World = Matrix.RotationAxis(New Vector3(Math.Cos(Tick / 550.0F), 1, Math.Sin(Tick / 550.0F)), Tick / 3000.0F)

Tick being the environment.tick output.

Question is this.

What the hell does this mean in dunce English:( ?

I try to understand every line of code in new programs so that I hopefully know how the program works, but this leave me cold.

My book says the sine of an angle = side opposite angle / hypotenuse. How does that translate to the above where there is no angle? Or is there?

Or am I so think I sholdn't even be considering this:(:(:(
 
Sines and Cosines are often used for their periodic nature.
If you have ever plotted a sine wave graph... it looks like a wave.
They are much more than an angle and ratio of opposite side to hypotenuse.
They are also applied in circles and Fourier transforms for speech, etc., which you (should) learn here before you get out of high school (the circle applications part).
In radians, the Sine and Cosine functions repeat themselves at 2 * Pi (equivalent to 360 degrees). You just need to know that it's periodic.
Tick / 550.0F is just a number that is divided by 550, which will slow down the sine wave.

You should really take some time to learn math related to sinusoids (sine and cosine), as it is fundamental, interesting, and very applicable. :)
 
Before I got out of high school?......lol

I don't think I will ever get into the realms of Doom, Quake type grahics but does this theory stand...

If this line of code;

Visual Basic:
Matrix.Multiply(Device.Transform.World, Matrix.RotationX(X * PI / 180))

will always rotate the x axis then do I need to worry about how it does, just accept that it does?

From a dunces point of view that is? lol :)
 
The Matrix object is included with DirectX, so you don't *have* to know how it works, but it is recommended that you know how it works. (especially to figure out the order to apply matrix transformations.)
As for the rotation part, (X * PI / 180) is just converting a value in X from degrees to radians.
If X = 360 (degrees), then X * PI / 180 = 2*Pi (radians equal to 360 degrees). :)
 
OK, so here is a very hopefull request:)

This zip file contains a project which I have learned from my DX9 book. I have created it from scratch to ensure I get it, which I am confident I do:)

What I can't seem to do is to get the square to rotate either clockwise or anticlockwise.

I have read the sample matrix demo that comes with the SDK but to no avail.

Is there some kind guru out there who could modify the code with 'idiot comment lines' so I can learn from it?

I've been trawlling the web all day trying to find tutorials but can find any to help:(

[edit] Robby removed binaries from zip[/edit]
 

Attachments

Last edited by a moderator:
OK.....I gone an dunnit:):)

I used the code I created in the attached file and merged it with the sample in the SDK.

It has taken me all night, but by golly I have done it and can sort of say now by trial an error I sort of grasp what it's about.

I'll just tidy up the code and then post it here, LESS the binaries! Sorry about that Robby:(
 
Back
Top