29#ifndef CM_SPATIAL_VECTOR_H
30#define CM_SPATIAL_VECTOR_H
32#include "foundation/PxVec3.h"
33#include "foundation/PxVecMath.h"
34#include "foundation/PxTransform.h"
54 : linear(lin), pad0(0.0f), angular(ang), pad1(0.0f)
71 static PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVector zero() {
return SpatialVector(PxVec3(0),PxVec3(0)); }
75 return SpatialVector(linear+v.linear,angular+v.angular);
78 PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVector operator-(
const SpatialVector& v)
const
80 return SpatialVector(linear-v.linear,angular-v.angular);
85 return SpatialVector(-linear,-angular);
88 PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVector operator *(PxReal s)
const
90 return SpatialVector(linear*s,angular*s);
93 PX_CUDA_CALLABLE
PX_FORCE_INLINE void operator+=(
const SpatialVector& v)
99 PX_CUDA_CALLABLE
PX_FORCE_INLINE void operator-=(
const SpatialVector& v)
107 return angular.magnitude() + linear.magnitude();
110 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal dot(
const SpatialVector& v)
const
112 return linear.dot(v.linear) + angular.dot(v.angular);
117 return linear.isFinite() && angular.isFinite();
120 PX_CUDA_CALLABLE
PX_FORCE_INLINE Cm::SpatialVector scale(PxReal l, PxReal a)
const
122 return Cm::SpatialVector(linear*l, angular*a);
141 : pad0(0.0f), pad1(0.0f)
143 top.x = v[0]; top.y = v[1]; top.z = v[2];
144 bottom.x = v[3]; bottom.y = v[4]; bottom.z = v[5];
148 : top(top_), pad0(0.0f), bottom(bottom_), pad1(0.0f)
165 static PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVectorF Zero() {
return SpatialVectorF(PxVec3(0), PxVec3(0)); }
169 return SpatialVectorF(top + v.top, bottom + v.bottom);
172 PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVectorF operator-(
const SpatialVectorF& v)
const
174 return SpatialVectorF(top - v.top, bottom - v.bottom);
179 return SpatialVectorF(-top, -bottom);
182 PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVectorF operator *(PxReal s)
const
184 return SpatialVectorF(top*s, bottom*s);
187 PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVectorF multiply(
const SpatialVectorF& v)
const
189 return SpatialVectorF(top.multiply(v.top), bottom.multiply(v.bottom));
198 PX_CUDA_CALLABLE
PX_FORCE_INLINE void operator += (
const SpatialVectorF& v)
204 PX_CUDA_CALLABLE
PX_FORCE_INLINE void operator -= (
const SpatialVectorF& v)
212 return top.magnitude() + bottom.magnitude();
217 return top.magnitudeSquared() + bottom.magnitudeSquared();
220 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal innerProduct(
const SpatialVectorF& v)
const
222 return bottom.dot(v.top) + top.dot(v.bottom);
230 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal dot(
const SpatialVectorF& v)
const
232 return top.dot(v.top) + bottom.dot(v.bottom);
235 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal dot(
const SpatialVector& v)
const
237 return bottom.dot(v.angular) + top.dot(v.linear);
243 a.top = top.cross(v.top);
244 a.bottom = top.cross(v.bottom) + bottom.cross(v.top);
250 return SpatialVectorF(top.abs(), bottom.abs());
255 return SpatialVectorF(rot.rotate(top), rot.rotate(bottom));
258 PX_CUDA_CALLABLE
PX_FORCE_INLINE SpatialVectorF rotateInv(
const PxTransform& rot)
const
260 return SpatialVectorF(rot.rotateInv(top), rot.rotateInv(bottom));
265 return top.isFinite() && bottom.isFinite();
270 const bool tValid = ((
PxAbs(top.x) <= maxV) && (
PxAbs(top.y) <= maxV) && (
PxAbs(top.z) <= maxV));
271 const bool bValid = ((
PxAbs(bottom.x) <= maxV) && (
PxAbs(bottom.y) <= maxV) && (
PxAbs(bottom.z) <= maxV));
273 return tValid && bValid;
276 PX_CUDA_CALLABLE
PX_FORCE_INLINE Cm::SpatialVectorF scale(PxReal l, PxReal a)
const
278 return Cm::SpatialVectorF(top*l, bottom*a);
283 val[0] = top.x; val[1] = top.y; val[2] = top.z;
284 val[3] = bottom.x; val[4] = bottom.y; val[5] = bottom.z;
287 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal& operator [] (
const PxU32 index)
289 PX_ASSERT(index < 6);
292 return bottom[index-3];
295 PX_CUDA_CALLABLE
PX_FORCE_INLINE const PxReal& operator [] (
const PxU32 index)
const
297 PX_ASSERT(index < 6);
300 return bottom[index-3];
307} PX_ALIGN_SUFFIX(16);
318 top.x = v[0]; top.y = v[1]; top.z = v[2];
319 bottom.x = v[3]; bottom.y = v[4]; bottom.z = v[5];
323 : top(top_), bottom(bottom_)
370 PX_CUDA_CALLABLE
PX_FORCE_INLINE void operator += (
const SpatialVectorF& v)
382 PX_CUDA_CALLABLE
PX_FORCE_INLINE void operator -= (
const SpatialVectorF& v)
400 return bottom.
dot(v.top) + top.
dot(v.bottom);
403 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal innerProduct(
const SpatialVectorF& v)
const
405 return bottom.
dot(v.top) + top.
dot(v.bottom);
410 return top.
dot(v.top) + bottom.
dot(v.bottom);
413 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal dot(
const SpatialVectorF& v)
const
415 return top.
dot(v.top) + bottom.
dot(v.bottom);
421 a.top = top.
cross(v.top);
422 a.bottom = top.
cross(v.bottom) + bottom.
cross(v.top);
448 const bool tValid = ((top.x <= maxV) && (top.y <= maxV) && (top.z <= maxV));
449 const bool bValid = ((bottom.x <= maxV) && (bottom.y <= maxV) && (bottom.z <= maxV));
451 return tValid && bValid;
454 PX_CUDA_CALLABLE
PX_FORCE_INLINE Cm::UnAlignedSpatialVector scale(PxReal l, PxReal a)
const
456 return Cm::UnAlignedSpatialVector(top*l, bottom*a);
461 val[0] = top.x; val[1] = top.y; val[2] = top.z;
462 val[3] = bottom.x; val[4] = bottom.y; val[5] = bottom.z;
465 PX_CUDA_CALLABLE
PX_FORCE_INLINE PxReal& operator [] (
const PxU32 index)
467 PX_ASSERT(index < 6);
468 return (&top.x)[index];
471 PX_CUDA_CALLABLE
PX_FORCE_INLINE const PxReal& operator [] (
const PxU32 index)
const
473 PX_ASSERT(index < 6);
474 return (&top.x)[index];
496 aos::V3Add(angular, other.angular)); }
499 angular = aos::V3Add(angular, other.angular);
504 aos::V3Sub(angular, other.angular)); }
511 angular = aos::V3Sub(angular, other.angular);
Definition CmSpatialVector.h:46
PX_CUDA_CALLABLE PX_FORCE_INLINE SpatialVector(const PxVec3 &lin, const PxVec3 &ang)
Construct from two PxcVectors.
Definition CmSpatialVector.h:53
PX_CUDA_CALLABLE PX_FORCE_INLINE SpatialVector()
Default constructor.
Definition CmSpatialVector.h:49
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE float dot(const PxVec3 &v) const
returns the scalar product of this and other.
Definition PxVec3.h:276
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 cross(const PxVec3 &v) const
cross product
Definition PxVec3.h:284
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 abs() const
returns absolute values of components;
Definition PxVec3.h:376
PX_CUDA_CALLABLE PX_FORCE_INLINE float magnitudeSquared() const
returns the squared magnitude
Definition PxVec3.h:175
PX_CUDA_CALLABLE PX_FORCE_INLINE float magnitude() const
returns the magnitude
Definition PxVec3.h:183
PX_CUDA_CALLABLE PX_INLINE bool isFinite() const
returns true if all 3 elems of the vector are finite (not NAN or INF, etc.)
Definition PxVec3.h:156
GLM_FUNC_QUALIFIER vec< 3, T, Q > cross(vec< 3, T, Q > const &x, vec< 3, T, Q > const &y)
Definition func_geometric.inl:175
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_INLINE void rotate(const Gu::Box &src, const PxMat34 &mtx, Gu::Box &obb)
recomputes the OBB after an arbitrary transform by a 4x4 matrix.
Definition GuBoxConversion.h:100
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
PX_INLINE PxStrideIterator< T > operator+(int i, PxStrideIterator< T > it)
Addition operator.
Definition PxStrideIterator.h:323
Definition CmSpatialVector.h:134
PX_CUDA_CALLABLE PX_FORCE_INLINE SpatialVectorF(const PxVec3 &top_, const PxVec3 &bottom_)
Construct from two PxcVectors.
Definition CmSpatialVector.h:147
PX_CUDA_CALLABLE PX_FORCE_INLINE SpatialVectorF()
Default constructor.
Definition CmSpatialVector.h:137
Definition CmSpatialVector.h:483
Definition CmSpatialVector.h:310
PX_CUDA_CALLABLE PX_FORCE_INLINE UnAlignedSpatialVector()
Default constructor.
Definition CmSpatialVector.h:313
PX_CUDA_CALLABLE PX_FORCE_INLINE UnAlignedSpatialVector(const PxVec3 &top_, const PxVec3 &bottom_)
Construct from two PxcVectors.
Definition CmSpatialVector.h:322
Definition PxVecMathAoSScalar.h:52
Definition PxVecMathAoSScalar.h:77