SOFA API  7226d276
Open source framework for multi-physics simuation
sofa::defaulttype::RigidCoord< 3, real > Class Template Reference

#include <RigidCoord.h>

Static Public Attributes

static constexpr sofa::Size total_size = 7
 Compile-time constant specifying the number of scalars within this vector (equivalent to the size() method) More...
 
static constexpr sofa::Size spatial_dimensions = 3
 Compile-time constant specifying the number of dimensions of space (NOT equivalent to total_size for rigids) More...
 

Protected Attributes

Vec3 center
 
Quat orientation
 

Public Member Functions

constexpr RigidCoord (const Vec3 &posCenter, const Quat &orient)
 
constexpr RigidCoord ()
 
template<typename real2 >
constexpr RigidCoord (const RigidCoord< 3, real2 > &c)
 
constexpr void clear ()
 
template<typename real2 >
constexpr void operator= (const RigidCoord< 3, real2 > &c)
 
constexpr void operator= (const Vec3 &p)
 
void operator+= (const Deriv &dg)
 
constexpr RigidCoord< 3, real > operator+ (const Deriv &dg) const
 
constexpr RigidCoord< 3, real > operator- (const RigidCoord< 3, real > &a) const
 
constexpr RigidCoord< 3, real > operator+ (const RigidCoord< 3, real > &a) const
 
constexpr RigidCoord< 3, real > operator- () const
 
constexpr void operator+= (const RigidCoord< 3, real > &a)
 
template<typename real2 >
constexpr void operator*= (real2 a)
 
template<typename real2 >
constexpr void operator/= (real2 a)
 
template<typename real2 >
constexpr RigidCoord< 3, real > operator* (real2 a) const
 
template<typename real2 >
constexpr RigidCoord< 3, real > operator/ (real2 a) const
 
constexpr Real operator* (const RigidCoord< 3, real > &a) const
 dot product, mostly used to compute residuals as sqrt(x*x) More...
 
constexpr real norm2 () const
 
real norm () const
 Euclidean norm. More...
 
constexpr Vec3 & getCenter ()
 
constexpr Quat & getOrientation ()
 
constexpr const Vec3 & getCenter () const
 
constexpr const Quat & getOrientation () const
 
constexpr Vec3 rotate (const Vec3 &v) const
 
constexpr RigidCoord< 3, real > rotate (const RigidCoord< 3, real > &c) const
 
constexpr Vec3 inverseRotate (const Vec3 &v) const
 
constexpr Vec3 translate (const Vec3 &v) const
 
constexpr RigidCoord< 3, real > translate (const RigidCoord< 3, real > &c) const
 
constexpr void multRight (const RigidCoord< 3, real > &c)
 Apply a transformation with respect to itself. More...
 
constexpr Vec3 mult (const Vec3 &v) const
 compute the product with another frame on the right More...
 
constexpr RigidCoord< 3, real > mult (const RigidCoord< 3, real > &c) const
 compute the product with another frame on the right More...
 
template<class Mat >
void fromMatrix (const Mat &m)
 Set from the given matrix. More...
 
void toMatrix (sofa::type::Mat< 3, 3, real > &m) const
 Write to the given 3x3 matrix. More...
 
void toMatrix (sofa::type::Mat< 4, 4, real > &m) const
 Write to the given 4x4 matrix. More...
 
constexpr void toHomogeneousMatrix (HomogeneousMat &m) const
 
template<class Mat >
void writeRotationMatrix (Mat &m) const
 
constexpr void writeOpenGlMatrix (float m[16]) const
 Write the OpenGL transformation matrix. More...
 
constexpr Vec3 projectPoint (const Vec3 &v) const
 Apply the transform to a point, i.e. project a point from the child frame to the parent frame (translation and rotation) More...
 
constexpr Vec3 projectVector (const Vec3 &v) const
 Apply the transform to a vector, i.e. project a vector from the child frame to the parent frame (rotation only, no translation added) More...
 
constexpr Vec3 unprojectPoint (const Vec3 &v) const
 Apply the inverse transform to a point, i.e. project a point from the parent frame to the child frame (translation and rotation) More...
 
constexpr Vec3 unprojectVector (const Vec3 &v) const
 Apply the inverse transform to a vector, i.e. project a vector from the parent frame to the child frame (rotation only, no translation) More...
 
constexpr Vec3 pointToParent (const Vec3 &v) const
 obsolete. Use projectPoint. More...
 
constexpr Vec3 pointToChild (const Vec3 &v) const
 obsolete. Use unprojectPoint. More...
 
constexpr real * ptr ()
 
constexpr const real * ptr () const
 
constexpr real & operator[] (Size i)
 Access to i-th element. More...
 
constexpr const real & operator[] (Size i) const
 Const access to i-th element. More...
 
Tests operators
constexpr bool operator== (const RigidCoord< 3, real > &b) const
 
constexpr bool operator!= (const RigidCoord< 3, real > &b) const
 

Static Public Member Functions

static RigidCoord rand (SReal a)
 Random rigid transform composed of 3 random translations and 3 random Euler angles. More...
 
static constexpr RigidCoord< 3, real > identity ()
 
template<typename V >
static constexpr HomogeneousVec toHomogeneous (V v, real r=1.)
 create a homogeneous vector from a 3d vector More...
 
template<typename V >
static constexpr Vec3 fromHomogeneous (V v)
 create a 3d vector from a homogeneous vector More...
 
static constexpr Size max_size ()
 
static constexpr Size size ()
 

Friends

std::ostream & operator<< (std::ostream &out, const RigidCoord< 3, real > &v)
 write to an output stream More...
 
std::istream & operator>> (std::istream &in, RigidCoord< 3, real > &v)
 read from an input stream More...
 

Attribute details

◆ center

template<typename real >
Vec3 sofa::defaulttype::RigidCoord< 3, real >::center
protected

◆ orientation

template<typename real >
Quat sofa::defaulttype::RigidCoord< 3, real >::orientation
protected

◆ spatial_dimensions

template<typename real >
constexpr sofa::Size sofa::defaulttype::RigidCoord< 3, real >::spatial_dimensions = 3
staticconstexpr

Compile-time constant specifying the number of dimensions of space (NOT equivalent to total_size for rigids)

◆ total_size

template<typename real >
constexpr sofa::Size sofa::defaulttype::RigidCoord< 3, real >::total_size = 7
staticconstexpr

Compile-time constant specifying the number of scalars within this vector (equivalent to the size() method)

Constructor details

◆ RigidCoord() [1/3]

template<typename real >
constexpr sofa::defaulttype::RigidCoord< 3, real >::RigidCoord ( const Vec3 &  posCenter,
const Quat &  orient 
)
inlineconstexpr

◆ RigidCoord() [2/3]

template<typename real >
constexpr sofa::defaulttype::RigidCoord< 3, real >::RigidCoord ( )
inlineconstexpr

◆ RigidCoord() [3/3]

template<typename real >
template<typename real2 >
constexpr sofa::defaulttype::RigidCoord< 3, real >::RigidCoord ( const RigidCoord< 3, real2 > &  c)
inlineconstexpr

Function details

◆ clear()

template<typename real >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::clear ( )
inlineconstexpr

◆ fromHomogeneous()

template<typename real >
template<typename V >
static constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::fromHomogeneous ( V  v)
inlinestaticconstexpr

create a 3d vector from a homogeneous vector

◆ fromMatrix()

template<typename real >
template<class Mat >
void sofa::defaulttype::RigidCoord< 3, real >::fromMatrix ( const Mat &  m)
inline

Set from the given matrix.

◆ getCenter() [1/2]

template<typename real >
constexpr Vec3& sofa::defaulttype::RigidCoord< 3, real >::getCenter ( )
inlineconstexpr

◆ getCenter() [2/2]

template<typename real >
constexpr const Vec3& sofa::defaulttype::RigidCoord< 3, real >::getCenter ( ) const
inlineconstexpr

◆ getOrientation() [1/2]

template<typename real >
constexpr Quat& sofa::defaulttype::RigidCoord< 3, real >::getOrientation ( )
inlineconstexpr

◆ getOrientation() [2/2]

template<typename real >
constexpr const Quat& sofa::defaulttype::RigidCoord< 3, real >::getOrientation ( ) const
inlineconstexpr

◆ identity()

template<typename real >
static constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::identity ( )
inlinestaticconstexpr

◆ inverseRotate()

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::inverseRotate ( const Vec3 &  v) const
inlineconstexpr

◆ max_size()

template<typename real >
static constexpr Size sofa::defaulttype::RigidCoord< 3, real >::max_size ( )
inlinestaticconstexpr

◆ mult() [1/2]

template<typename real >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::mult ( const RigidCoord< 3, real > &  c) const
inlineconstexpr

compute the product with another frame on the right

◆ mult() [2/2]

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::mult ( const Vec3 &  v) const
inlineconstexpr

compute the product with another frame on the right

◆ multRight()

template<typename real >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::multRight ( const RigidCoord< 3, real > &  c)
inlineconstexpr

Apply a transformation with respect to itself.

◆ norm()

template<typename real >
real sofa::defaulttype::RigidCoord< 3, real >::norm ( ) const
inline

Euclidean norm.

◆ norm2()

template<typename real >
constexpr real sofa::defaulttype::RigidCoord< 3, real >::norm2 ( ) const
inlineconstexpr

Squared norm. For the rotation we use the xyz components of the quaternion. Note that this is not equivalent to the angle, so a 2d rotation and the equivalent 3d rotation have different norms.

◆ operator!=()

template<typename real >
constexpr bool sofa::defaulttype::RigidCoord< 3, real >::operator!= ( const RigidCoord< 3, real > &  b) const
inlineconstexpr

◆ operator*() [1/2]

template<typename real >
constexpr Real sofa::defaulttype::RigidCoord< 3, real >::operator* ( const RigidCoord< 3, real > &  a) const
inlineconstexpr

dot product, mostly used to compute residuals as sqrt(x*x)

◆ operator*() [2/2]

template<typename real >
template<typename real2 >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::operator* ( real2  a) const
inlineconstexpr

◆ operator*=()

template<typename real >
template<typename real2 >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::operator*= ( real2  a)
inlineconstexpr

◆ operator+() [1/2]

template<typename real >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::operator+ ( const Deriv &  dg) const
inlineconstexpr

◆ operator+() [2/2]

template<typename real >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::operator+ ( const RigidCoord< 3, real > &  a) const
inlineconstexpr

◆ operator+=() [1/2]

template<typename real >
void sofa::defaulttype::RigidCoord< 3, real >::operator+= ( const Deriv &  dg)
inline

◆ operator+=() [2/2]

template<typename real >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::operator+= ( const RigidCoord< 3, real > &  a)
inlineconstexpr

◆ operator-() [1/2]

template<typename real >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::operator- ( ) const
inlineconstexpr

◆ operator-() [2/2]

template<typename real >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::operator- ( const RigidCoord< 3, real > &  a) const
inlineconstexpr

◆ operator/()

template<typename real >
template<typename real2 >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::operator/ ( real2  a) const
inlineconstexpr

◆ operator/=()

template<typename real >
template<typename real2 >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::operator/= ( real2  a)
inlineconstexpr

◆ operator=() [1/2]

template<typename real >
template<typename real2 >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::operator= ( const RigidCoord< 3, real2 > &  c)
inlineconstexpr

◆ operator=() [2/2]

template<typename real >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::operator= ( const Vec3 &  p)
inlineconstexpr

◆ operator==()

template<typename real >
constexpr bool sofa::defaulttype::RigidCoord< 3, real >::operator== ( const RigidCoord< 3, real > &  b) const
inlineconstexpr

◆ operator[]() [1/2]

template<typename real >
constexpr real& sofa::defaulttype::RigidCoord< 3, real >::operator[] ( Size  i)
inlineconstexpr

Access to i-th element.

◆ operator[]() [2/2]

template<typename real >
constexpr const real& sofa::defaulttype::RigidCoord< 3, real >::operator[] ( Size  i) const
inlineconstexpr

Const access to i-th element.

◆ pointToChild()

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::pointToChild ( const Vec3 &  v) const
inlineconstexpr

obsolete. Use unprojectPoint.

◆ pointToParent()

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::pointToParent ( const Vec3 &  v) const
inlineconstexpr

obsolete. Use projectPoint.

◆ projectPoint()

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::projectPoint ( const Vec3 &  v) const
inlineconstexpr

Apply the transform to a point, i.e. project a point from the child frame to the parent frame (translation and rotation)

◆ projectVector()

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::projectVector ( const Vec3 &  v) const
inlineconstexpr

Apply the transform to a vector, i.e. project a vector from the child frame to the parent frame (rotation only, no translation added)

◆ ptr() [1/2]

template<typename real >
constexpr real* sofa::defaulttype::RigidCoord< 3, real >::ptr ( )
inlineconstexpr

◆ ptr() [2/2]

template<typename real >
constexpr const real* sofa::defaulttype::RigidCoord< 3, real >::ptr ( ) const
inlineconstexpr

◆ rand()

template<typename real >
static RigidCoord sofa::defaulttype::RigidCoord< 3, real >::rand ( SReal  a)
inlinestatic

Random rigid transform composed of 3 random translations and 3 random Euler angles.

Parameters
aRange of each random value: (-a,+a)
Returns
random rigid transform

◆ rotate() [1/2]

template<typename real >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::rotate ( const RigidCoord< 3, real > &  c) const
inlineconstexpr

◆ rotate() [2/2]

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::rotate ( const Vec3 &  v) const
inlineconstexpr

◆ size()

template<typename real >
static constexpr Size sofa::defaulttype::RigidCoord< 3, real >::size ( )
inlinestaticconstexpr

◆ toHomogeneous()

template<typename real >
template<typename V >
static constexpr HomogeneousVec sofa::defaulttype::RigidCoord< 3, real >::toHomogeneous ( V  v,
real  r = 1. 
)
inlinestaticconstexpr

create a homogeneous vector from a 3d vector

◆ toHomogeneousMatrix()

template<typename real >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::toHomogeneousMatrix ( HomogeneousMat &  m) const
inlineconstexpr

◆ toMatrix() [1/2]

template<typename real >
void sofa::defaulttype::RigidCoord< 3, real >::toMatrix ( sofa::type::Mat< 3, 3, real > &  m) const
inline

Write to the given 3x3 matrix.

◆ toMatrix() [2/2]

template<typename real >
void sofa::defaulttype::RigidCoord< 3, real >::toMatrix ( sofa::type::Mat< 4, 4, real > &  m) const
inline

Write to the given 4x4 matrix.

◆ translate() [1/2]

template<typename real >
constexpr RigidCoord<3, real> sofa::defaulttype::RigidCoord< 3, real >::translate ( const RigidCoord< 3, real > &  c) const
inlineconstexpr

◆ translate() [2/2]

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::translate ( const Vec3 &  v) const
inlineconstexpr

◆ unprojectPoint()

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::unprojectPoint ( const Vec3 &  v) const
inlineconstexpr

Apply the inverse transform to a point, i.e. project a point from the parent frame to the child frame (translation and rotation)

◆ unprojectVector()

template<typename real >
constexpr Vec3 sofa::defaulttype::RigidCoord< 3, real >::unprojectVector ( const Vec3 &  v) const
inlineconstexpr

Apply the inverse transform to a vector, i.e. project a vector from the parent frame to the child frame (rotation only, no translation)

◆ writeOpenGlMatrix()

template<typename real >
constexpr void sofa::defaulttype::RigidCoord< 3, real >::writeOpenGlMatrix ( float  m[16]) const
inlineconstexpr

Write the OpenGL transformation matrix.

◆ writeRotationMatrix()

template<typename real >
template<class Mat >
void sofa::defaulttype::RigidCoord< 3, real >::writeRotationMatrix ( Mat &  m) const
inline

Related details

◆ operator<<

template<typename real >
std::ostream& operator<< ( std::ostream &  out,
const RigidCoord< 3, real > &  v 
)
friend

write to an output stream

◆ operator>>

template<typename real >
std::istream& operator>> ( std::istream &  in,
RigidCoord< 3, real > &  v 
)
friend

read from an input stream