• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
vaironl

How do Rotation Matrix Work?

5 posts in this topic

Hello everyone,

I saw a couple of articles on wikipeadia and other places about rotating shapes using Matrix.

I do not have much experience with Matrix in general, but I can do my reasearch.

Now the thing that I would love to make is, kind of my own rotating shape, from scratch in java.
I mean drawing everything without any help from any library and then using a rotational matrix (Sorry if the name is wrong!) and make a 3D picture. I already have done 2D graphics.

I would just love to go through the work and understand how exactly it works.

Thanks for the help, if possible.
0

Share this post


Link to post
Share on other sites
A matrix is used to transform vectors from one space to another. So if your model is built in its own coordinate system, we can use the tranform to move it's local position to a relative one in another coordinate system. We can also invert the process, taking vectors from another coordinate system, and transform them into local coordinates.

Generally, an object will have it's vertices defined in local space. These vertices can be moved into a common space, often called "world" space, by using a transform.
For an example, take a unit cube, centered at origin. It's vertices will have coordinates ranging from -0.5 to +0.5 in each axis, XYZ. If we want to make a cube at <6,0,0> in world space, we take each vertiex and multiply it by a transform matrix, resulting in world space vertices ranging from +5.5 to +6.5 on the x axis.

A camera is simply another object in space, and we can use the second point in the first paragraph, to translate the world space vectors into the cameras local frame, often called view space. Continuing with the example above, If we want to view the cube, we could make a camera, and set it at origin, but looking down the X axis. The cameras world transform would transform the local XYZ axes to the world , so that the local Z axis is aligned with the world X, and the local X axis would be aligned with the world -Z. The inverse of that transform will take the world space vertices of the cube, and transform them into view space. Our cube in view space would now have x and y coords ranging from -0.5 to +0.5, with it's Z coordinates ranging from 5.5 to 6.5.

finally, projecting the 3d view space coordinates into screen space can be done with whats known as a projection matrix, so that objects farther back appear smaller and so forth. this would make the far side of the cube slightly smaller than the near side.

I would suggest finding a good resource such as http://www.euclideanspace.com/ to get a better, more visual idea of what is going on. When I first learned about matrices it made 0 sense to me. Thanks to the explanations Martin Baker gave, I was able to piece together a basic 3d renderer in PHP, which gave me enough confidence to start tackling DirectX and I'm still going strong.
0

Share this post


Link to post
Share on other sites
Hello. To understand a transformation matrix, you must first understand transformation. This is all trig:
http://www.khanacademy.org/math/trigonometry/v/polar-coordinates-1 Check the ones on polar coordinates.

Once you understand that, you should know that rotation matrices are just a fancy way of doing those operations. Matrices are just used for performance, you do not need them to implement transformation. There are many people who get introduced to matrices before they even know (or they forgot) how transformation works, and because of that many people find the concept confusing. Edited by Xcrypt
0

Share this post


Link to post
Share on other sites
I hate to be the bearer of bad news, but all you really need to know right now, is that nobody knows what the matrix is. If you multiply two of them together it catenates them and then both transformations will occur. The reason you can do this is because 4x4 matrix with multiplication and addition defined as we normally do form a ring. In a ring multiplication is associative, so it matters not which matrices gets multiplied when, but only that they are properly pre-multiplied or post-multiplied depending on what you want to accomplish. For now just follow the formulas that tell you how to form the matrix, where to put the cosine and sine of the angles, and you'll have to be careful about transposes, since some graphics libraries use row vectors and some use column vectors. With row vectors, you post multiply by the matrices, with column vectors you pre multiply them, and when you switch from one to the other you must transpose the matrices. This will potentially cause for the most confusion.

The best way to think of matrices as some kind of black box, a function, that takes a vector as an input and ouputs a vector that has been transformed. With 4x4 matrices, which is what he use in video games, because they allow us to use the magical homogenous transormation, the input will be a 4x1 vector. Just set the w component to 1 for positional transformations, and you're good to go. Don't worry about setting w to antyhing else.

Now the reason I said I had bad news, is because if you truly want to understand matrices, you got to go to college to learn about linear algebra. I'm sorry to say it, but without a strong mathematical background if you tried to just read about matrices you'd think they are just some mystical force in the universe that somehow just work. There are all sorts of interesting reasons why we can pull off what we do in video games using matrices, such as orthogonal transformations, and the like, but it really takes a strong mathematical background to get understand it.

I will say this, however, if you get a degree in mathematics, you can still get a job in video games, and also since you have a degree in math and not computer science, people won't ask you to fix their computers all the time cause they don't know you know about computers.
-1

Share this post


Link to post
Share on other sites
Rotation matrices work by using the matrix form of simple trig identities for angle addition:

[url="http://en.wikipedia.org/wiki/Trigonometric_identity#Angle_sum_and_difference_identities"]http://en.wikipedia.org/wiki/Trigonometric_identity#Angle_sum_and_difference_identities[/url]


As far as 3D geometry matrices go, they aren't mystical at all. Think of them as four vectors packed together. During multiplication with other matrices or vectors, the first three "vectors" inside the matrix modify the coordinate axis (X,Y,Z) directions, and the last one modifies where the "origin" is. In this form, a matrix "converts coordinate spaces".

You can render the contents of a matrix to the screen and visualize it by splitting the matrix down into each vector and then using those to plot lines on the screen. If you were to render a standard 3D model using the matrix, you would notice that it would be rendered at the same position and orientation as the three lines.
0

Share this post


Link to post
Share on other sites
[quote name='Beem' timestamp='1353293176' post='5002209']
Now the reason I said I had bad news, is because if you truly want to understand matrices, you got to go to college to learn about linear algebra. I'm sorry to say it, but without a strong mathematical background if you tried to just read about matrices you'd think they are just some mystical force in the universe that somehow just work. There are all sorts of interesting reasons why we can pull off what we do in video games using matrices, such as orthogonal transformations, and the like, but it really takes a strong mathematical background to get understand it.
[/quote]
Some matrix operations may require college-level linear algebra to understand, but rotation certainly isn't one of them. 8th grade math was all I needed to understand them...

@OP: Do you understand how 2D rotation matrices work? It's much easier to understand 3D rotation matrices if you understand 2D rotation matrices, but I don't want to go over 2D matrices if you're already familiar with them, and I won't talk about 3D rotation matrices if you don't understand 2D rotation matrices.

Also, you said you haven't done much with matrix math. I suggest you check out the Khan Academy to learn about matrix math. [url=http://www.khanacademy.org/math/algebra/algebra-matrices/v/introduction-to-matrices]Start with the first video[/url]. I suggest watching the first 9 videos. The others are optional, as far as understanding rotation matrices goes.
0

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  
Followers 0