PDA

View Full Version : Affine and Homogenous vectors



Sly
23-03-2005, 12:29 PM
Does anyone understand the difference between an affine vector and a homogenous vector? I'm looking through the Geometry.pas unit by Mike Lischke and it declares affine and homogenous vector and matrix types. The only real difference I can see is that affine vectors have three elements and homogenous vectors have four elements. It is really annoying because in the functions that he provides, half of them use TAffineVector and the other half use THomogenousVector. They are incompatible types because of the difference in size.

In our proprietary engine at Krome Studios, we have a Vector3 (used for positions, rotations and scales) and a Vector4 (used for colours). Our Vector3 is actually four elements with the fourth element always being a value of one (this is because the PS2's native vector type is 128 bits, so it's faster to use a four element vector than to use a three element vector).

I've tried looking up Google for the difference, but all I could find were complex mathematical explanations that used big words in a whole bunch of theory. I need layman's terms and practical examples. :)

siim
23-03-2005, 02:46 PM
If I unerstand it correctly then vec4's are used, because it would not be mathematically correct if you would try to multiply 4x4 matrix with vec3 (remember the matrix multiplication - same number of rows needed as first matrix has cols) and you need 4x4 matrix if you want represent translation, rotation, scale and perspective.

homogenous vector (x, y, z, t) is basically (x/t, y/t, z/t) affine vector

Edit: fixed something

Sly
23-03-2005, 10:49 PM
What we do here at work with Vector3's is always set the w component (what you specify as t) to 1.0, which fits with your equation for an affine vector.

I'd like to modify Geometry.pas to only use homogenous vectors, but it contains some assembly and that's where I get lost.