Skip to main content
gamedev.net
🔒 Locked

homogeneous coordinates

Started by quasar3d Jul 10, 2004 at 2:24 PM 0 replies 1.7k views
Original Post
quasar3d
quasar3d
I am creating a simple software rasterizer, and now I am working on the viewport clipping part, in homogeneous space, and to clip a triangle, I have to interpolate between two vertices. So can you actually interpolate between a homogeneous coordinate like you would do with other coordinates (ie. linearily interpolate all coordinates, including the w part)? I don't think you can, and that to interpolate between them, you first have to make the w coordinates equal, and then do your calculations. Now that made me wonder, is a homogeneous 4D vector in fact a 3D version of a fraction, with the w-coordinate being the denominator? If you want to add fractions, you have to make the denominators equal, as we all learnd in elementary school. Now if it's that way, the common operators for these homogeneous vectors would just be the 3D versions, taken into account that it are all fractions. So addition then be this:

Vector4D operator + (const Vector4D &b) const
{
	return Vector4D(
	x * b.w + b.x * w,
	y * b.w + b.y * w,
	z * b.w + b.z * w,
	w * b.w);
}
and multiplication would be this

Vector4D operator * (float b) const
{
	return Vector4D(
		x * b,
		y * b,
		z * b,
		w);
}
All with all, it seems to work well, but I couldn't find anything on the internet about homogeneous vectors, only homogeneous coordinates, but I don't think you can do calculations on coordinates, can you? So is there actually something like a homogeneous vector, and if so, is it like this?
Steadtler
Steadtler
""Now that made me wonder, is a homogeneous 4D vector in fact a 3D version of a fraction, with the w-coordinate being the denominator?""

I think you have got it backward.
Say you have a vector in 3d space (a,b,c)
Its equivalents in homogeneous coordinate would be
(a*w, b*w, c*w, w), w != 0

(if w = 0, then the vector is a direction instead of a coordinate)

Now if you want to interpolate, I strongly suggest putting the coordinates back to the normal 3d space by dividing by w, and interpolating in that space with the usual algorithms. You can always put it back in the homogeneous space afterwards.

**

Coordinates ARE vectors, they are the vecors from the origin to that point. I know you can do at least SOME vector operation on homogeneous coordinates. For example, if A and B are homogeneous coordinates with w != 0, then
AxB is the line in homogeneous form that passe by A and B! (x is the cross product)

And if C and D are lines in homogeneous form, then
CxD is thier meeting point. If C and D are parralel, w will equal 0, they meet at infinitum!

Homogeneous coordinates are magic.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.