[geeks] DaveM: Crays up?
dave at cca.org
dave at cca.org
Sun Nov 24 04:44:01 CST 2002
wstan at xs4all.nl writes:
>Just curious if you can give me an example of a small
>matrix and why you might encounter them in your work more than
>larger ones. Is a matrix the same as an array? Sorry
>if the question seems stupid. I am on a slow learning path
>to Fortran (and maybe Java). I even downloaded the
>documentation for "VAX Macro" since it might be a proper
>thing to learn about when I get my VAXen up and actually
>doing something.
Not sure what Josh is doing, but 3d graphics is *FILLED* with
4x4 matrices. (2d graphics with 3x3 matrices.)
If you represent your (x,y,z) coordinates as a matrix, then all of
the standard linear transformations (translate, scale, shear, rotate)
can be performed with matrix multiplications. Which sounds kinda
neat, but not efficient, *but*! If you have matrices:
a = Your (x,y,z) point
b = translate (6,-7,12)
c = rotate 43 degrees
d = scale by 1.2
(Or, a more common example: rotate around (3,4,5) is actually:
translate (3,4,5), rotate, translate (-3,-4,-5).)
And
a X b X c X d = transformed coordinates
Then if you make a matrix of the various transformations:
e = b X c X d
Then multiplying any (x,y,z) matrix by matrix e will give
you that entire sequence of transformations in one operation.
Neat-o.
(The reason 3d takes 4x4 is that one of the transformations
can't be done in 3x3. I think it's translation, but I don't
remember.)
And... calculating matrix operations is filled with a = b X c + d,
which is one of the reasons that fused "multiply/add" instructions
are so common on high-end CPUs.
------ David Fischer ------- dave at cca.org ------- http://www.cca.org ------
----------- When Heaven is full, the dead shall walk the earth. -----------
More information about the geeks
mailing list