18 #ifndef BT_SPATIAL_ALGEBRA_H 19 #define BT_SPATIAL_ALGEBRA_H 37 m_bottomVec = angular;
48 m_bottomVec += angular;
104 m_bottomVec = linear;
115 m_bottomVec += angular;
122 m_bottomVec[0] += lx;
123 m_bottomVec[1] += ly;
124 m_bottomVec[2] += lz;
147 template <
typename SpatialVectorType>
148 void cross(
const SpatialVectorType &b, SpatialVectorType &out)
const 150 out.m_topVec = m_topVec.
cross(b.m_topVec);
151 out.m_bottomVec = m_bottomVec.
cross(b.m_topVec) + m_topVec.
cross(b.m_bottomVec);
153 template <
typename SpatialVectorType>
154 SpatialVectorType
cross(
const SpatialVectorType &b)
const 156 SpatialVectorType out;
157 out.m_topVec = m_topVec.
cross(b.m_topVec);
158 out.m_bottomVec = m_bottomVec.
cross(b.m_topVec) + m_topVec.
cross(b.m_bottomVec);
195 m_topLeftMat = topLeftMat;
196 m_topRightMat = topRightMat;
197 m_bottomLeftMat = bottomLeftMat;
202 m_topLeftMat += topLeftMat;
203 m_topRightMat += topRightMat;
204 m_bottomLeftMat += bottomLeftMat;
240 template <
typename SpatialVectorType>
242 SpatialVectorType &outVec,
247 outVec.m_topVec = m_rotMat * inVec.m_topVec;
248 outVec.m_bottomVec = -m_trnVec.
cross(outVec.m_topVec) + m_rotMat * inVec.m_bottomVec;
250 else if (outOp ==
Add)
252 outVec.m_topVec += m_rotMat * inVec.m_topVec;
253 outVec.m_bottomVec += -m_trnVec.
cross(outVec.m_topVec) + m_rotMat * inVec.m_bottomVec;
255 else if (outOp == Subtract)
257 outVec.m_topVec -= m_rotMat * inVec.m_topVec;
258 outVec.m_bottomVec -= -m_trnVec.
cross(outVec.m_topVec) + m_rotMat * inVec.m_bottomVec;
262 template <
typename SpatialVectorType>
264 SpatialVectorType &outVec,
269 outVec.m_topVec = m_rotMat * inVec.m_topVec;
270 outVec.m_bottomVec = m_rotMat * inVec.m_bottomVec;
272 else if (outOp ==
Add)
274 outVec.m_topVec += m_rotMat * inVec.m_topVec;
275 outVec.m_bottomVec += m_rotMat * inVec.m_bottomVec;
277 else if (outOp == Subtract)
279 outVec.m_topVec -= m_rotMat * inVec.m_topVec;
280 outVec.m_bottomVec -= m_rotMat * inVec.m_bottomVec;
284 template <
typename SpatialVectorType>
286 SpatialVectorType &outVec,
291 outVec.m_topVec = m_rotMat.
transpose() * inVec.m_topVec;
292 outVec.m_bottomVec = m_rotMat.
transpose() * (inVec.m_bottomVec + m_trnVec.
cross(inVec.m_topVec));
294 else if (outOp ==
Add)
296 outVec.m_topVec += m_rotMat.
transpose() * inVec.m_topVec;
297 outVec.m_bottomVec += m_rotMat.
transpose() * (inVec.m_bottomVec + m_trnVec.
cross(inVec.m_topVec));
299 else if (outOp == Subtract)
301 outVec.m_topVec -= m_rotMat.
transpose() * inVec.m_topVec;
302 outVec.m_bottomVec -= m_rotMat.
transpose() * (inVec.m_bottomVec + m_trnVec.
cross(inVec.m_topVec));
306 template <
typename SpatialVectorType>
308 SpatialVectorType &outVec,
313 outVec.m_topVec = m_rotMat.
transpose() * inVec.m_topVec;
314 outVec.m_bottomVec = m_rotMat.
transpose() * inVec.m_bottomVec;
316 else if (outOp ==
Add)
318 outVec.m_topVec += m_rotMat.
transpose() * inVec.m_topVec;
319 outVec.m_bottomVec += m_rotMat.
transpose() * inVec.m_bottomVec;
321 else if (outOp == Subtract)
323 outVec.m_topVec -= m_rotMat.
transpose() * inVec.m_topVec;
324 outVec.m_bottomVec -= m_rotMat.
transpose() * inVec.m_bottomVec;
332 const btMatrix3x3 r_cross(0, -m_trnVec[2], m_trnVec[1],
333 m_trnVec[2], 0, -m_trnVec[0],
334 -m_trnVec[1], m_trnVec[0], 0);
342 else if (outOp ==
Add)
348 else if (outOp == Subtract)
356 template <
typename SpatialVectorType>
357 SpatialVectorType
operator*(
const SpatialVectorType &vec)
359 SpatialVectorType out;
365 template <
typename SpatialVectorType>
376 template <
typename SpatialVectorType>
389 #endif //BT_SPATIAL_ALGEBRA_H
btSpatialForceVector & operator+=(const btSpatialForceVector &vec)
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
const btVector3 & getLinear() const
These spatial algebra classes are used for btMultiBody, see BulletDynamics/Featherstone.
btSpatialMotionVector & operator*=(const btScalar &s)
void setValue(const btScalar &ax, const btScalar &ay, const btScalar &az, const btScalar &lx, const btScalar &ly, const btScalar &lz)
void addValue(const btScalar &ax, const btScalar &ay, const btScalar &az, const btScalar &lx, const btScalar &ly, const btScalar &lz)
btSpatialForceVector & operator-=(const btSpatialForceVector &vec)
btSpatialForceVector(const btVector3 &angular, const btVector3 &linear)
btSpatialMotionVector operator+(const btSpatialMotionVector &vec) const
void addLinear(const btVector3 &linear)
void symmetricSpatialOuterProduct(const SpatialVectorType &a, const SpatialVectorType &b, btSymmetricSpatialDyad &out)
btSpatialForceVector operator-(const btSpatialForceVector &vec) const
btSpatialMotionVector operator-() const
btMatrix3x3 outerProduct(const btVector3 &v0, const btVector3 &v1)
void addLinear(const btVector3 &linear)
btMatrix3x3 transpose() const
Return the transpose of the matrix.
void setValue(const btScalar &ax, const btScalar &ay, const btScalar &az, const btScalar &lx, const btScalar &ly, const btScalar &lz)
void addAngular(const btVector3 &angular)
void addValue(const btScalar &ax, const btScalar &ay, const btScalar &az, const btScalar &lx, const btScalar &ly, const btScalar &lz)
btSpatialForceVector operator*(const btScalar &s) const
const btVector3 & getLinear() const
void setVector(const btVector3 &angular, const btVector3 &linear)
btSymmetricSpatialDyad & operator-=(const btSymmetricSpatialDyad &mat)
const btVector3 & getAngular() const
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
btScalar dot(const btVector3 &v) const
Return the dot product.
void setLinear(const btVector3 &linear)
btSpatialForceVector operator+(const btSpatialForceVector &vec) const
void setAngular(const btVector3 &angular)
void setAngular(const btVector3 &angular)
btVector3 can be used to represent 3D points and vectors.
btSpatialForceVector operator-() const
btSpatialForceVector(const btScalar &ax, const btScalar &ay, const btScalar &az, const btScalar &lx, const btScalar &ly, const btScalar &lz)
void cross(const SpatialVectorType &b, SpatialVectorType &out) const
void setMatrix(const btMatrix3x3 &topLeftMat, const btMatrix3x3 &topRightMat, const btMatrix3x3 &bottomLeftMat)
btScalar dot(const btSpatialForceVector &b) const
SpatialVectorType cross(const SpatialVectorType &b) const
const btVector3 & getAngular() const
btMatrix3x3 m_bottomLeftMat
btSpatialMotionVector & operator-=(const btSpatialMotionVector &vec)
void setVector(const btVector3 &angular, const btVector3 &linear)
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
static btMatrix3x3 Add(const btMatrix3x3 &a, const btMatrix3x3 &b)
void addVector(const btVector3 &angular, const btVector3 &linear)
btSpatialMotionVector & operator+=(const btSpatialMotionVector &vec)
void addVector(const btVector3 &angular, const btVector3 &linear)
btSymmetricSpatialDyad(const btMatrix3x3 &topLeftMat, const btMatrix3x3 &topRightMat, const btMatrix3x3 &bottomLeftMat)
btSpatialMotionVector operator*(const btScalar &s) const
void addAngular(const btVector3 &angular)
void addMatrix(const btMatrix3x3 &topLeftMat, const btMatrix3x3 &topRightMat, const btMatrix3x3 &bottomLeftMat)
void setLinear(const btVector3 &linear)
void setIdentity()
Set the matrix to the identity.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btMatrix3x3 m_topRightMat
btSpatialMotionVector(const btVector3 &angular, const btVector3 &linear)
btSpatialMotionVector operator-(const btSpatialMotionVector &vec) const
btSpatialForceVector operator*(const btSpatialMotionVector &vec)