Archived

This topic is now archived and is closed to further replies.

Math is like a box o' chocalates...

This topic is 5824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

...you always know what you''re gonna get. More or less. Did I get your attention? Are you here looking for a question to answer? Good. Math, to me, is probably the most interesting subject ever. The past few days, I''ve been scouring the Internet looking for any information I can on trigonometry, matrices, and vectors. Algebra is always fun to me, because I always know what to do (well not always). I''m really wanting to learn graphics programming, and I want to learn all the math I can to get better and better all around. So, let me ask some things from anyone who can answer me. 1) I know that a vector has not only a magnitude, like a scalar, but also a sense and direction. In physics, force is a vector, as it must be applied in some direction with some magnitude. But, I''ve also read that a vector is "basically a set of coordinates..." as in (x,y,z). I''m confused. What is a vector exactly? 2) I''ve been reading some stuff on matrices. To me, these are like the jerk next door-- they''re pretty cool once you get to know them. I''ll put it that way. May I ask how a matrix relates to the Cartesian coordinate system we''ve all seen since th 6th grade? I was under the impression that a matrix IS a coordinate system, but now my ideas of it are changing. Help me out if you can, please. I''d really like to know all that I can learn on this subject. I''d appreciate it.

Share this post


Link to post
Share on other sites
Well there are vectors and vector quantities...its all really just sematics though. I would not get snagged in the definition.

Go read Matrix Math in the Articles and Resource section...and whatever else pertains to math you like

Share this post


Link to post
Share on other sites
I have taken several courses on linear algebra. Perhaps I can help.

1. A vector can be defined as a "distance with direction". This definition is quite crytpic, though. A simple way to think of it is as an arrow in an n-dimensional world. The direction of this arrow tells you what direction to move in. And the length of the arrow tells you the magnitude of the movement.

2. A matrix is a transformation. Imagine you have a vector in a 3D world. When you multiply this vector by a matrix, you will get a new vector, that will point in a different direction. Thus, the matrix has transformed the original vector into a new vector. So imagine you have a monster in a game that is made up of polygons, which are each made up of vectors. When you multiply each vector in the monster by a matrix, you might rotate, or stretch, or skew, or ... the monster. Thus, matrices are really a way of transforming vectors into different vectors. A technical way of saying this is that a matrix is a transformation that maps vectors in one vector space into corresponding vectors in another vector space. If you study linear algebra or abstract algebra you will learn all about transformations and mappings.

Share this post


Link to post
Share on other sites
What Mr. DirectX just said is true, but here is some more stuff to get you started.

1. A vector is not only an arrow with a direction and a length, it can indeed be represented as a (x,y,z) 3D coordinate. (Assuming we are talking 3D here.) The base of the arrow is at (0,0,0) and the arrowhead is at (x,y,z). This defines both the direction and the length (or magnitude) of the vector. To extract the magnitude, simply use Pythagoras: magnitude = sqrt(x*x + y*y z*z).

2. General matrices are a bit difficult to envision. But some matrices that are used in graphics programming are pretty easy. An example of this is a 3x3 rotation matrix. You see, the 3 columns of such a matrix can be seen as 3 vectors. These vectors are all of unit length, meaning that their magnitude is 1. Also, they are all orthogonal to eachother, in essence they form a new coordinate system. And it gets even better, this coordinate system specifies the rotation contained in this matrix! You see the coordinate frame in a rotation matrix is actually the main coordinate frame rotated. When you transform a vector using the rotation matrix, it gets rotated in the same way that the coordinate system in the matrix was rotated.

I hope that made some sense to you. Otherwise, check out the great vector and matrix tutorials of Gamedev.net, Flipcode.com and such sites.

Share this post


Link to post
Share on other sites
A vector is *nothing more* than a length with a direction.
But it can be used to represent a lot of things, what
you want it to be.

If you chose your vector to start at the position (0,0,0)
within a 3D coordinate system, the three components of
the vector represent the point at (x,y,z).
But the vector can also start from a point different to (0,0,0),
and then, it doesn''t represent the coord.system''s point at vector''s x,y,z.
BUT: it''s exacltly the same vector. A vector does not contain
it''s "own position" information, so a vector is just a
length with a direction, where the direction is defined
by the ratio of it''s components against each other,
nothing more. But it can represent what you want.


Velocity for example, is a vector used in physics.
You can treat it like the length(magnitude) of the
velocity vector is the "velocity value", like 10 meters/second,
and the direction corresponds to a moving direction in 3D.
Also here, it doesn''t matter where the moving object is
( = the start point of the velocity vector), if the objects
moves with constant speed in constant direction, the
velocity vector won''t change. But you can have an extra
vector, the object''s "position vector", to keep track of
*where* the object is. That position-vector ''p'' starts from
origin(0,0,0), and therfore represents the
point (p_x , p_y , p_z)
in the coordinate system the object is moving in.
Imagine an arrow, starting at (0,0,0), and ending at
the object''s "middle".


If you increase the velocity, the vector gets longer.
If you don''t change the direction, the ratios of its components
stay same. You can check this by using the formula given by
Scarab0.
Let''s say vector v = (2.0, -1.5, 4.0)
its length is sqareroot( 2*2 + (-1.5)*(-1.5) + 4*4 ) = 4.717
We want to double the length, so we double all components:
2*v = (4.0, -3,0, 8.0), the length is 9.434, exactly the double of 4.717.

It''s easier to visualize that in 2D. Draw some 2D vectors
into a cartesian 2D coordinate system
and play around with the values. You can see how the direction
changes with the altering ratio of the two components (x,y)
(you can draw a 3D vector onto your paper sheet,
but it''s not very useful here)



Share this post


Link to post
Share on other sites
A point is a position vector. It represents a direction and distance from the origin (0, 0). Look at polar coordinates; (r, theta) represents first a magnitude and then an angle; hence it is a vector (which we always say begins at the origin) - but it is also a point.

In other words: A vector is commonly expressed in component form (x, y, z). If you were to travel along vector (x, y, z) starting at the origin, then you would end up at point (x, y, z).

Share this post


Link to post
Share on other sites
quote:
Original post by Scarab0
magnitude = sqrt(x*x + y*y z*z).



I''ve seen that before. I always thought it was silly though, because is sqrt(x^2 + y^2 + z^2) not equal to (|x| + |y| + |z|)?

Share this post


Link to post
Share on other sites

quote: " I''ve seen that before. I always thought it was silly though, because is sqrt(x^2 + y^2 +
z^2) not equal to (|x| + |y| + |z|)? "

Nope.
Your x,y,z are real numbers here, where || means "absolute value", in other words
"without sign".

The eq. sqrt(x^2 + y^2 + z^2) is just pythagoras, and sqares are not done by
not caring about the sign, of course :-)
(well, of course, after squaring, you''ll have no sign, though)

With vectors, || means "magnitude". So |vector| = sqrt(vx^2 + vy^2 + vz^2).


Share this post


Link to post
Share on other sites
quote:
Original post by Some Guy
What is a vector exactly?


Just so you have another viewpoint to work from: in a physical sense, a vector is a (1,3) [(1,4) for normalized coords, I guess] example of a tensor, which is a mathematical construct used to formulate high-level physics "stuff".

quote:

I ask how a matrix relates to the Cartesian coordinate system we''ve all seen since th 6th grade? I was under the impression that a matrix IS a coordinate system, but now my ideas of it are changing.


A matrix by itself means very little. In an equation, a matrix is best explained as part of a formulation for a system of linear equations (hence, linear equations).

For example:
|a b||x| = |A|
|c d||y| |B|

represents the set of equations

ax + by = A
cx + dy = B

You will find that typically some matrices come to seem as if they have external meaning (for example, translation and rotation matrices), but in a mathematical sense these are solutions to their respective linear systems.

Hope that helps,
ld

Share this post


Link to post
Share on other sites
At the very core these matrices are just an organized way of dealing with the manipulation of coordinates. Take for example the rotation of a point P(x0,y0,z0) around the z-axis by an angle phi. This problem is in essence an application of the sums and differences formulas for trig; that is the equations

sin(a+b) = sin a cos b + cos a sin b
sin(a-b) = sin a cos b - cos a sin b
cos(a+b) = cos a cos b - sin a sin b
cos(a-b) = cos a cos b + sin a sin b.

First, the coordinates of P in polar are
x0 = r cos(theta)
y0 = r sin(theta)
the z coordinates stays the same

After rotation by an angle phi the new coordinates are
x1=r cos(theta+phi)=r cos(theta) cos(phi) - r sin(theta) sin(phi)
y1=r sin(theta+phi)=r sin(theta) cos(phi) - r cos(theta) sin(phi)

But we can substitute the original coordinates x0, y0 in the formula. Thus we get

x1 = x0 cos(phi) - y0 sin(phi)
y1 = y0 cos(phi) + x0 sin(phi)

Now the matrix for rotation about the z axis is
| cos a -sin a 0 0 | * | x |
| sin a cos a 0 0 | | y |
| 0 0 1 0 | | z |
| 0 0 0 1 | | 1 |

and this is equal to
| x cos a - y sin a |
| x sin a + y cos a |
| z |
| 1 |
Notice anything familiar between this result and
x1 = x0 cos(phi) - y0 sin(phi)
y1 = y0 cos(phi) + x0 sin(phi)

Matrices don''t really bring any new mathematical concepts just a nice way of representing the algebra that manipulates the vertices.

Share this post


Link to post
Share on other sites
quote:
Original post by UnshavenBastard

quote: " I've seen that before. I always thought it was silly though, because is sqrt(x^2 + y^2 +
z^2) not equal to (|x| + |y| + |z|)? "

Nope.
Your x,y,z are real numbers here, where || means "absolute value", in other words
"without sign".

The eq. sqrt(x^2 + y^2 + z^2) is just pythagoras, and sqares are not done by
not caring about the sign, of course :-)
(well, of course, after squaring, you'll have no sign, though)

With vectors, || means "magnitude". So |vector| = sqrt(vx^2 + vy^2 + vz^2).





Huh.

I would have said, "(x + y + z)" instead of "(|x| + |y| + |z|)," but suppose x is negative. Then x * x would equal a positive number, and sqrt(x * x) would equal either x, being a negative, or -x, being a positive (remember that multiplying a number by -1 changes its sign). For this reason, I decided to use the absolute values of x, y, and z, but now I know that || can also mean the magnitude of a vector.



Edited by - Some Guy on January 3, 2002 2:35:16 PM

Share this post


Link to post
Share on other sites
If you''re specifically interested in math as it applies to game programming, you may want to check out the math course at http://www.gameinstitute.com. I haven''t taken the math course, but I''m currently enrolled in a couple of their other courses, and they''re quite good (the BSP/PVS course is especially excellent).

Share this post


Link to post
Share on other sites