Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / [C++] Matrix rotations, vector and euler....how do I use them???

Author
Message
Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 7th Dec 2010 21:24
Hey all,

I'm confused about certain rotations and how to use and convert them. I was writing a wrapper for Bullet Physics but got stuck with Matrix rotations. What I don't understand is why anyone would use anything other then degrees. Questions:

What are Euler angles?
Are Euler angles the same as vector rotations?
Are Euler/vector measured in degrees (0-360 on 3 axis)
What is Matrix rotation?
Why would you use matrix rotation?
How do convert matrix rotations to euler/vector/whatever DBPro uses?

I need to do all this in C++ so don't just say get EZRotate. And I can't use the GDK for this either.

Thanks,
Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Dec 2010 22:34 Edited at: 7th Dec 2010 22:35
So uh...

What does this do in the DBP boards?

Also, check
http://en.wikipedia.org/wiki/Euler_angles
http://en.wikipedia.org/wiki/Rotation_matrix

Cheers!
Sven B

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Dec 2010 22:53
Quote: "why anyone would use anything other then degrees"


Euler angles and quaternions and matrices are not equivalents to using degrees, they are ways of representing a rotation in 3d.

"using degrees" does not help at all in representing a rotation in 3d.

Euler angles attempt to solve the problem by having 3 axis around which to rotate. The problems are that the 3 axis are not independent. A rotation about 2 axis in 3d can be equal to a rotation about the 3rd (this is known as gimbal lock). This makes it impossible to combine angles without converting to another representation.

Quaternions and matrices are other ways of representing rotations. Matrices essentially map points local to the object to points in the world, and quaternions are difficult to simplify further than that they are a mathematical way of representing a rotation (and optionally a uniform scale) in 3d. Both quaternions and matrices make it easy to combine rotations and can be converted between one another easily.

The main problem with matrices is that they can represent other transformations as well as rotations, so you have to normalise them occasionally to prevent skews and stretches due to floating point errors.

The main problem with quaternions is that they are a "pure" mathematical idea and are difficult to visualise.

[b]
Eminent
16
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 7th Dec 2010 23:30
EZRotate works with C++.


Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 1st Feb 2011 00:52
I know I'm gonna buy it

@Diggsey:

I understand the bit about Euler angles not being independent, but the rest is all very confusing. I haven't the faintest idea what normalising is, yet I see it all the time. Is it simple to explain?

Thanks,
Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Feb 2011 02:27
^^ that's probably the problem!

Normalizing means setting a vector's length to one.

I'd suggest you read up on vectors first, then matrices, and then *maybe* quaternions, though you probably won't ever need them.

Matrices are useful because they represent linear transformations. If I were to say "rotate this object, then translate it, rotate it again, then scale it about the origin, I could just say V'=V*R*T*R*S, and then applying the inverse of the matrices would undo the transformations.

It's math plain and simple. First of all, if you don't already, LEARN SOME MATRIX ALGEBRA! If you don't know how to multiply two matrices, or what inverting a matrix does, then learn it!!!

Here's information about vector algebra: It's great to know if you're doing anything mathy in 3d.
http://www.neurofuzzydev.com/V/D/index.htm

This is a good website about rotation matrices:
http://www.cprogramming.com/tutorial/3d/rotationMatrices.html


An Euler angle is a rotation about an axis. So if you rotate a vector around the x axis, then the y axis, then the Z axis, that's a euler rotation, and the amount you rotate each axis by is the corresponding Euler Angle.

With matrices, you can represent these kinds of transformations really easily. If you have a rotation around the x axis, matrix X, and a rotation around the y axis, matrix Y, X*Y will give you another rotation.

I found this page to be pretty good also:
http://mathforum.org/mathimages/index.php/Transformation_Matrix

Login to post a reply

Server time is: 2026-07-18 02:08:33
Your offset time is: 2026-07-18 02:08:33