Archived

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

Math Silly Questions

This topic is 4983 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

Altought I know to program in C/C++ and asm, some of opengl and direct3d, and other things, there are some aspects of math programming that I don''t understand good yet: - Rotation/Trans Matrices: confused between: - CW & CCW - matrix of vector columns or row vectors - pre & post multiplication by a vector or matrix - Left-Hand System & Right-Hand system - Dot product visual representation, from two vectors you get an scalar, but I can''t visualize it in cartesian space clearly. - Homogeneus coordinates in general, but in particular, point vs. vector (w=0 or w=1 ??), why not all 3 dimensions, 3x3 matrix, 3x1 vector, 3x1 point ... I don''t remember anything else, when it came to my head I''ll post it. thanke

Share this post


Link to post
Share on other sites
That's a lot of geometry & algebra... I'll try and contribute something:

I'm not quite sure what 'trans' is abbreviated from in that first point. I don't want to patronise you by explaining the difference between a rotation and a translation, neither do I want to explain the intricacies of a transformation matrix since that's probably not what you're asking.

The CW/CCW issue is a fairly simple one. These terms are mutually exclusive only for triangles, since four or more vertices may be specified in an order that may be both CW and CCW or arguably neither.
The basic idea is that when specifying the vertices of a triangle, you can only do them one at a time, and so your 3D API takes advantage of this by noting the order in which they were specified. It can then go on to selectively render only triangles facing certain directions, among many other things.
To find which way your triangle is facing, imagine looking at a point in one of the centres of the triangle from wherever your camera is. Then the vertices make a loop about this point (or possibly a line if your camera is in exactly the wrong place). Traversing this loop in the order the vertices were specified results in motion of a clockwise or anticlockwise manner about this central point. The rest is up to your API.

For the third problem, first you should understand that a vector is really a matrix in disguise. Imagine a 1x4 matrix: This is a 4-dimensional column vector. Similarly a 3x1 matrix is a 3D row-vector. Now you just have to think of either stacking a few row vectors (of the same dimension) on top of one another [say, five of them] and you end up with a matrix of row-vectors [a 3x5 matrix in this example]. I'm sure you can complete the corresponding example for column-vectors.

Pre and post multiplication is best demonstrated by an example, so I'll force myself to give one. Consider two 2x2 matrices:

01 = A
42

11 = B
02

Now I'll convince you that matrix multiplication is not commutative; that is to say (AB != BA):

02 = AB
48

43 = BA
84

If you're not familiar with matrix multiplication, take my word for it.
So now we have two ways of multiplying two matrices (or vectors, being special cases of matrices) - pre and post. Usually when performing matrix operations, we have a matrix (or more often a vector) representing something, the subject matrix, and another matrix that represents an operation to perform, namely the object matrix. The pre and post bits apply to the object matrix:
Pre-multiplication: [Transformation Matrix][Subject Matrix]
Post-multiplication: [Subject Matrix][Transformation Matrix]

Point five:
The two different coordinate systems are a consequence of a lack of communication over the development of 3D standards, I'm sure. Basically, when arranging your three orthogonal axes (X, Y and Z) although it may seem like more, there are actually only two ways to do it. Given two 'arrangements', you can do exactly one of the following:
-=Rotate one of them so that it is identical to the other
-=Rotate one so that it is a mirror-image of the other
And so the left and right-handed systems are born. They are mirror images of each other and do exactly the same things but in different directions (kind of like optical isomers, if you like chemistry ). Neither has become universally accepted, which causes quite some trouble for lots of people. If I'm not mistaken, OpenGL uses a left-handed system, whilst Direct3D uses the RHS.
Know which you're using, and try to stick with it.

Now the dot-product issue...
So you know how it's calculated but can't visualise it? Try this:
Imagine you're carrying a big sheet of glass on a windy day. If you carry the glass so that it faces the wind edge-on, it's easy to move with it - the wind is imposing no force on the glass. However, if you then turn a corner so that the wind contacts the whole flat surface of the glass, things get trickier.
Here, the direction of the wind is one vector, and the face normal of the glass is the direction of other vector. The force imposed by the wind on the glass (a scalar) is the result of the dot-product of these two vectors.
When they are parallel, your glass is receiving the full blast of the wind, and the force is maximises. Conversely, when the face-normal is perpendicular to the wind, you feel no force at all (let's say the glass is infinitely thin and you aren't affected by the wind). This is the effect of the cosine component of the dot-product.
Now if the wind is blowing five times harder, the force is factored correspondingly (but note that it still has no effect if you're facing the right way). Similarly, carrying a bigger sheet of glass will increase the magnitude of your other vector, giving the same effect - a bigger dot-product.
I appreciate that this example is a little contrived, but hopefully it gives you an idea of how the dot-product affects the real world.

Well my fingers are all typed-out, so I'll leave the last point to someone else.

Hope this helps.

[edited by - TheAdmiral on April 20, 2004 4:27:49 PM]

Share this post


Link to post
Share on other sites
I am grateful for your explanation, especially the example of the dot-product

I'll clarify some points of my question:
- In rotation CW & CCW, giving a positive value of angle, I have see that in rotation matrix, I have observed that depending on what system you use, the final form of the matrix changes very much, depending on if you use LH or RH, and a CW or CCW rotation, and rotation formulas represented as a row or a column matrix, the final form of the matrix is similar but not equal.

- To matrix translation only affect row or column matrix, pre-post mult, and LH-RH coord system, I believe.


Having 3 vector v1,v2,v3, I mean about row-matrix:
{ x1 y1 z1 w1 ]
[ x2 y2 z2 w2 ] = M1
[ x3 y3 z3 w3 ]
[ 0 0 0 1 ]

and column-matrix:
{ x1 x2 x3 0 ]
[ y1 y2 y3 0 ] = M2
[ z1 z2 z3 0 ]
[ w1 w2 w3 1 ]

Pre: [ x y z w ] [ M ]
Post:
[ x ]
[ M2 ] [ y ]
[ z ]
[ w ]


About pre and post multiply(concatenation) of matrices:

being [Rx],[Ry],[Rz] 4x4 rotation matrices about aziz x,y,z respectively, and [Rxyz] rotation about x first, y second, and z later:

[Rxyz] = [Rx]*( [Ry]*[Rz] )
or
[Rxyz] = [Rx]*( [Rz]*[Ry] )
or
[Rxyz] = ( [Rx]*[Ry] )*[Rz]
or
[Rxyz] = ( [Ry]*[Rx] )*[Rz]

??


[edited by - Silly_con on April 20, 2004 7:14:36 PM]

Share this post


Link to post
Share on other sites