Why w is set to 0 by default in btVector3?

vaxon
Posts: 4
Joined: Wed Jul 24, 2013 9:52 pm

Why w is set to 0 by default in btVector3?

Post by vaxon »

btVector3 doesn't seem to use the fourth component (w), and IIUC, it's there for SIMD compatibility.
However, having w=1.0 seems to be a better choice that could simplify the translation from
3D to a 4D homogeneous coordinates in OpenGL.
We wouldn't need the following in getOpenGLMatrix:

Code: Select all

m[15] = btScalar(1.0);
BTW, the comment (and the docs) say:
/**@brief Fill an array representation
* @param m A pointer to a 15 element array (12 rotation(row major padded on the right by 1), and 3 translation */
However, "m" is really a pointer to a 16-element array.

Thanks,
V.
mobeen
Posts: 122
Joined: Thu May 05, 2011 11:47 am

Re: Why w is set to 0 by default in btVector3?

Post by mobeen »

From what I know, the maths point of view might be the reason:
vectors have w=0 and points have w=1.
Setting w=0 does not change the vector however it only displaces it to a new location.
Setting w=1 makes it a point which is modified when a translation is added.

From Bullets point of view it might also be for SIMD reasons. Just my 2 cents.