Archived

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

kelaklub

Point class

Recommended Posts

I am trying to implement general point, vector, and matrix classes which I plan to use for all my graphics, and game programming needs. Working on my point class, I decided to see what other more intelligent people on the web might have added to their point classes. On a web-site I saw the following for a constructor to be used in a point class. Is this useful, and if so would anyone know of a c++ implementation of this? And what the heck is a projective space, every where I look there are all these ( at least to me ) complex definitions, would anyone know of a simple way to explain what a projective space is? Thank you. Dipinder Sidhu ***************************************************************** aPoint(const FLOATxyzw p); The parameter p is assumed to hold the projective space coordinates of a point. Assuming fabs(p[3])>0, this constructor is equivalent to aPoint(p[0]/p[3],p[1]/p[3],p[2]/p[3]);. If p[3] is zero, then the projective space point is an ideal point. When this is the case, this constructor simply generates the point as: aPoint(p[0],p[1],p[2]);. *****************************************************************

Share this post


Link to post
Share on other sites
Ignore the 4th coordinate. Just always set it equal to 1.0 and all your calculations will be OK. I''m not sure what projective space is, honestly...
Unless, they mean projective coordinates. Those are 4-tuples (x,y,z,w) where the x,y,z are just three dimensional coordinates and w is just there for mathematical reasons. E.g., moving into the plane for simplicity, all transformations cannont be done with a 2x2 matrix. E.g., translations which need a 3x3 matrix. To solve this problem, you just tack a third (non-zero) coordinate onto your point (x,y,1) and multiply away.
In theory, after you multiply your point by your matrix, you need to scale all the other coordinates by the "dummy" one. However, if you just set it to 1, and you set your matrices up properly (so that the bottom row is 0,0,1), it will always remain 1. So you don''t really need to scale.
The exception to this last statement is when doing projection and lighting / shadow effects. But I don''t really do very much of that stuff so maybe somebody else can fill in the details.

Share this post


Link to post
Share on other sites
If I had to guess, it looks like they''re doing a form of compression on the vector/point (looses quality but you can stuff it all in one 32-bit number).

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites
The simpliest way to view it is the point after a projection transform. A prime example would be from the logical 3D space of the scene to the plane of the screen. That requires x and y be multiplied by sz/z where sz is the plane of the screen, i.e. the plane z=sz. Prior to completion of that projection it is projective space.

Share this post


Link to post
Share on other sites