• Advertisement
Sign in to follow this  

point/vector?

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

I have been wrestling with this recently and figured I ask here as a little improv poll ( since I dont know how to start a real poll in this forum ). Anyway I am curious how some of you out there handle points and vectors ( 2d and/or 3d ). Up until now I have always use vector to cover functionality for points and vectors since they are the same data structure anyway. Recently I broke it up just because I had so many functions that seemed to be vector specific but I am regetting it a little because I find I have to do a lot more casting/converting between points and vectors ( sometimes in very tight loops which seems bad ). So my question is do you have seperate vector point classes and if so why? or why not? Just as a note : I have a Point<type> base class so I can cover int/float/double types and vector is derived from Point<float>, does anyone have any horror stories about using templates that way? Jason

Share this post


Link to post
Share on other sites
Advertisement
I just use a vector class. A point to me is just a position vector. (Using homogenous transformations, vectors and points only differ by the value of the w component).

Share this post


Link to post
Share on other sites
Personally, I use seperate point and vector classes. If you code it right, converting between the two should be no-ops, at least in release builds.

Share this post


Link to post
Share on other sites
Same as above. It seems a popular method as far as I've seen. They differ so little so why bother writing two different classes.

Edit: SiCrane got a reply in before me, so my "Same as above" refers to the poster above him.

Share this post


Link to post
Share on other sites
for most things a single 4D vector class will suffice - however as you get more into it, seperate classes really do start making more sense. As Si said, in release builds there shouldn't be a problem converting between the two - but normally this happens less often than you think anyway.

Share this post


Link to post
Share on other sites
I represent points with vectors. It keeps things simple. I never have to worry about choosing what to use and when. In my spirit of keeping things simple I don't use templates to define type, I just use floats. If I need to use doubles or integers in the future I'll make the necessary changes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement