• 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
littletray26

A few quick math questions

14 posts in this topic

Okay, I picked up a book yesterday to help me further understand some math concepts to do with Vectors and Matrices. I'll list a few, correct me if I'm wrong? I just need to get my head around these.

D3DXVec3Normalize() - What does this do exactly? if I put in a vector (0, 5, 4.33) what would that return? (0, 1, 1) ??

D3DXVec3TransformCoord() - I used this yesterday in making a First Person Camera, though I do not know what it does. Example?

D3DXVec3Dot() - I have no idea what this does.

D3DXVec3Cross() - I think I know what this does. You give it 2 Vectors and it returns a Vector that is Right Angle to both given Vectors?

========================================

Can someone explain these to me better? Please don't suggest I go do a course or read a book because I'm not really all that good with Mathso I need an explanation is simple [b]ENGLISH[/b] rather than a bunch of math equations [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]

Thanks Edited by littletray26
0

Share this post


Link to post
Share on other sites
Just based on general 3D knowledge, I would assume:

- Normalize normalises a vector, e.g. returns a vector with the same direction but magnitude (length) of 1. [url="http://en.wikipedia.org/wiki/Normalized_vector"]http://en.wikipedia.org/wiki/Normalized_vector[/url]
- Dot gets the dot product of two vectors. [url="http://en.wikipedia.org/wiki/Dot_product"]http://en.wikipedia.org/wiki/Dot_product[/url]
- Cross gets the cross product of two vectors, and you're pretty much on the money with your answer. [url="http://en.wikipedia.org/wiki/Cross_product"]http://en.wikipedia.org/wiki/Cross_product[/url]

TransformCoord... not sure. I'm not a D3D guy.
0

Share this post


Link to post
Share on other sites
Normalize - divides each component of the vector by the vector's total length (the length of a vector v = (x, y, z) is computed by sqrt(x*x + y*y + z*z), also can be written as |v|). The length of the new vector is now equal to 1
.
TransformCoord - transforms the vector using the transformation defined by the matrix argument. The w component is assumed to be equal to 1. Read about matrix maths if you aren't sure what this means

Dot and Cross are two different ways of multiplying vectors together. Dot returns a single number, whereas Cross returns a vector

Dot - calculates the dot product of 2 vectors, which is the younger sibling of the cross product, speaking mathematically. If v1 = (a, b, c) and v2 = (d, e, f), then Dot(v1, v2) returns (a*d + b*e + c*f), the sum of the multiples of components from each vector. This is also equal to |v1||v2|cos(t), where t is the angle between the two vectors in 3D space, and also notice that Dot(v1, v1) = |v1||v1|cos(0) = |v1|[sup]2[/sup] - the dot product of the vector with itself is equal to the length squared, if you look at the two formulas this is easy to see. This is useful for many many things

Cross - calculates the cross product of 2 vectors. The returned vector is, as you said, perpendicular to the two vectors. If I set v3 = Cross(v1, v2), then the length of v3 is equal to: |v3| = |v1||v2|sin(t), where t is the angle between v1 and v2. Now if v1 and v2 are parallel then notice that t = 0, therefore the returned vector is (0, 0, 0).

Now the really interesting thing about Cross is that the answer is different if you pass in the two vectors in different orders, In other words, Cross(v1, v2) is not equal to Cross(v2, v1). (To be precise, Cross(v1, v2) = -Cross(v2, v1)). If you think about it, if v1 and v2 are (non-parallel) vectors, there are 2 possible vectors v3 and v4 perpendicular to v1 and v2 - they are the negative version of each other (v3 = -v4). For example, if v1 = (1, 0, 0) and v2 = (0, 1, 0) then you can easily see that v3 = (0, 0, 1) is perpendicular to both v1 and v2, but also v4 = (0, 0, -1) is as well! the Cross product of two vectors 'decides' which direction to return based on the order, so if you pass in the two arguments the other way around you will get the opposite direction.

Ok that was quite a lecture, if you still don't understand something then speak now or forever hold your peace [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]
1

Share this post


Link to post
Share on other sites
[quote name='littletray26' timestamp='1338507219' post='4945128']
D3DXVec3TransformCoord() - I used this yesterday in making a First Person Camera, though I do not know what it does. Example?
[/quote]

This is where a basic linear algebra course would help you. To answer your question: It transforms a vector by a transform matrix (and assumes the vector's 4th component is 1) and returns a result. Which is a fancy way of saying that it multiplies the vector into the matrix, and returns the resulting vector. Edited by Washu
0

Share this post


Link to post
Share on other sites
Sorry guys, you's are helping, I'm just slow :P

[quote name='jefferytitan' timestamp='1338512556' post='4945144']
Normalize normalises a vector, e.g. returns a vector with the same direction but magnitude (length) of 1
[/quote]

What do you mean "magnitude"?

Okay so D3DXVec3Dot() returns D3DXVECTOR3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z) ?
and D3DXVec3Cross() returns either a positive or negative value the represent a Vector that right angle to the given parameters?

I still don't really understand Normalizing or TransformCoord, only that normalizing has to do with 1 :c someone dumb it down for me, please? xD

Sorry, I really want to understand these but I'm finding it hard :/
0

Share this post


Link to post
Share on other sites
Sorry, D3DXVec3Dot() returns a number equal to (v1.x * v2.x + v1.y * v2.y + v1.z + v2.z) ?

What is the use of this?
0

Share this post


Link to post
Share on other sites
[quote name='jefferytitan' timestamp='1338512556' post='4945144']
Normalize normalises a vector, e.g. returns a vector with the same direction but magnitude (length) of 1.
[/quote]

Is the length the distance from the origin? So if I had like (0, 10, 0) it's length is 10? Or (0, 10, 5) is 15?
0

Share this post


Link to post
Share on other sites
[quote name='littletray26' timestamp='1338525771' post='4945199']
Is the length the distance from the origin? So if I had like (0, 10, 0) it's length is 10? Or (0, 10, 5) is 15?
[/quote]

A vector is often used to indicate a direction rather than a point, but the distance from the origin idea is close enough for magnitude. Think of it as the distance (as the crow flies) from the origin to the point. For example, (0, 1, 0) has length 1, (0, 1, 1) has length square root of 2 (roughly 1.4142).
0

Share this post


Link to post
Share on other sites
[quote name='littletray26' timestamp='1338525771' post='4945199']
[quote name='jefferytitan' timestamp='1338512556' post='4945144']
Normalize normalises a vector, e.g. returns a vector with the same direction but magnitude (length) of 1.
[/quote]

Is the length the distance from the origin? So if I had like (0, 10, 0) it's length is 10? Or (0, 10, 5) is 15?
[/quote]

Yes, if you picture yourself the vector as a point in 3D space, then magnitude of the vector is distance from the origin.
But your examples are wrong!

Magnitude of vector (0, 10, 0) really is 10
But magnitude of vector (0, 10, 5) isn't 15 but 11.18034...
15 is the distance from origin, but not the shortest (straight) distance, you simply went 10 units on the y axis and then 5 units parallel with the z axis, which made the resulting 15. But if you went straight from the origin to the point (0, 10, 5), you would get there in 11.18034 units.

How did I get this weird number?
Using thePythagorean theorem in 3D space:
magnitude[sup]2[/sup] = x[sup]2[/sup] + y[sup]2[/sup] + z[sup]2[/sup]
Where x, y, z are the elements of the vector. So in your example:
magnitude[sup]2[/sup] = 0[sup]2[/sup] + 10[sup]2[/sup] + 5[sup]2[/sup]
magnitude[sup]2[/sup] = 125
magnitude = 11.18034... Edited by Tom KQT
0

Share this post


Link to post
Share on other sites
Thank you guys! I think I get it now:

Normalization - Takes the 2 vectors and gives it a magnitude of 1. Same direction, different length.
Cross - returns a vector perpendicular to the 2 given vectors
Dot - Returns a float equal to (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) but I don't know when you would use it?
TranformCoords - Still have no idea. Anyone want to explain this one in its most basic definition? :P
0

Share this post


Link to post
Share on other sites
I refer you to this blog post I found that explains all the concepts above in plain English with game-related examples. Sounds like it's exactly what you're looking for: [url="http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-2/"]http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-2/[/url]

Hope it helps!
1

Share this post


Link to post
Share on other sites
[quote name='littletray26' timestamp='1338537052' post='4945238']
Normalization - Takes the 2 vectors and gives it a magnitude of 1. Same direction, different length.
[/quote]

Normalization - takes one vector, returns another vector with same direction, but length / magnitude of 1.

Dot product is actually used almost everywhere. For example, a simple lighting model would calculate the dot product between surface normal and light direction to get the light intensity at each fragment or vertex. If the surface normal and light directions aren't normalized vectors, the light intensity will be wrong (ie. scaled by the length of the normals).


D3DXVec3TransformCoord requires a little understanding of vectors and matrices. A vector may define many things, including a position in some space (for example local/object or world space).

- for example, if you model a 3D object, you'd typically create it around origo. In order to place this object else where than in origo in your game engine, you'll need a translation matrix which may be used to transform the object to a different location. Practically, a translation matrix contains a offset vector which tells how much the mesh has to be moved in certain direction. The matrix may contain also rotations so that the object may be rotated to different directions.

So a matrix can be used to transform a position from one space to another.

In computer graphics, typically you'll have several spaces such as :

- local space. Each object is defined in local space
- world space. Each object has a transform matrix which is used to transform from local space to world space.
- view space. Your camera has a camera matrix, which is used to transform position from world space to view space.
- projection/clip space. Your camera has a projection matrix which is used to transform a position from view space to projection space

And to mess things up a bit more, vector matrix multiply is practically few dot products.


Best regards! Edited by kauna
0

Share this post


Link to post
Share on other sites
[quote name='btower' timestamp='1338538429' post='4945241']
I refer you to this blog post I found that explains all the concepts above in plain English with game-related examples. Sounds like it's exactly what you're looking for: [url="http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-2/"]http://blog.wolfire....elopers-part-2/[/url]

Hope it helps!
[/quote]

That's awesome! I saved it for future reference ;) Thank you!
0

Share this post


Link to post
Share on other sites
[quote name='kauna' timestamp='1338539966' post='4945249']
[quote name='littletray26' timestamp='1338537052' post='4945238']
Normalization - Takes the 2 vectors and gives it a magnitude of 1. Same direction, different length.
[/quote]

Normalization - takes one vector, returns another vector with same direction, but length / magnitude of 1.

Dot product is actually used almost everywhere. For example, a simple lighting model would calculate the dot product between surface normal and light direction to get the light intensity at each fragment or vertex. If the surface normal and light directions aren't normalized vectors, the light intensity will be wrong (ie. scaled by the length of the normals).


D3DXVec3TransformCoord requires a little understanding of vectors and matrices. A vector may define many things, including a position in some space (for example local/object or world space).

- for example, if you model a 3D object, you'd typically create it around origo. In order to place this object else where than in origo in your game engine, you'll need a translation matrix which may be used to transform the object to a different location. Practically, a translation matrix contains a offset vector which tells how much the mesh has to be moved in certain direction. The matrix may contain also rotations so that the object may be rotated to different directions.

So a matrix can be used to transform a position from one space to another.

In computer graphics, typically you'll have several spaces such as :

- local space. Each object is defined in local space
- world space. Each object has a transform matrix which is used to transform from local space to world space.
- view space. Your camera has a camera matrix, which is used to transform position from world space to view space.
- projection/clip space. Your camera has a projection matrix which is used to transform a position from view space to projection space

And to mess things up a bit more, vector matrix multiply is practically few dot products.


Best regards!
[/quote]

Thank you for that lesson in math ;) :)
0

Share this post


Link to post
Share on other sites
The dot product is very intuitive especially when you use two unit length (... normalized... magnitude of 1) vectors for the input. If the vectors are pointing in the same direction, then the dot product is 1. If they are orthogonal (at right angle) then dot prod is 0. If they are pointing in opposite direction the dot prod is -1.

Now, if you go ahead and plot arccos (see [url="http://www.wolframalpha.com/input/?i=plot+acos+from+1+to+-1"]http://www.wolframal...os from 1 to -1[/url]), you will see that the dot prod of two unit vectors fed into acos gives you the angle between the vectors in radians. That is, acos(1) is 0, acos(0) is pi/2 and acos(-1) is pi.

Of course 0 radians is 0 degrees, pi/2 radians is 90 degrees, and pi radians is 180 degrees.

Dot prod is used for lighting calculations, and friction between two surfaces, and backface culling, and all kinds of other things. Try experimenting with non-unit vectors to see how it affects the dot product. Fun times.

I see that the link given above has a similar explanation. :) Oh well. Edited by taby
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