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

#include <RigidCoord.h>

Static Public Attributes

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

Public Member Functions

constexpr RigidCoord (const Vec2 &posCenter, const Real &orient)
 
constexpr RigidCoord ()
 
constexpr void clear ()
 
constexpr void operator+= (const RigidDeriv< 2, real > &a)
 
constexpr RigidCoord< 2, real > operator+ (const RigidDeriv< 2, real > &a) const
 
constexpr RigidCoord< 2, real > operator- (const RigidCoord< 2, real > &a) const
 
constexpr RigidCoord< 2, real > operator+ (const RigidCoord< 2, real > &a) const
 
constexpr RigidCoord< 2, real > operator- () const
 
constexpr void operator+= (const RigidCoord< 2, real > &a)
 
template<typename real2 >
constexpr void operator*= (real2 a)
 
template<typename real2 >
constexpr void operator/= (real2 a)
 
template<typename real2 >
constexpr RigidCoord< 2, real > operator* (real2 a) const
 
template<typename real2 >
constexpr RigidCoord< 2, real > operator/ (real2 a) const
 
constexpr Real operator* (const RigidCoord< 2, real > &a) const
 dot product, mostly used to compute residuals as sqrt(x*x) More...
 
Real norm2 () const
 Squared norm. More...
 
real norm () const
 Euclidean norm. More...
 
constexpr Vec2getCenter ()
 
constexpr RealgetOrientation ()
 
constexpr const Vec2getCenter () const
 
constexpr const RealgetOrientation () const
 
Vec2 rotate (const Vec2 &v) const
 
Vec2 inverseRotate (const Vec2 &v) const
 
constexpr Vec2 translate (const Vec2 &v) const
 
constexpr RigidCoord< 2, real > translate (const RigidCoord< 2, real > &c) const
 
constexpr void multRight (const RigidCoord< 2, real > &c)
 Apply a transformation with respect to itself. More...
 
constexpr Vec2 mult (const Vec2 &v) const
 compute the product with another frame on the right More...
 
constexpr RigidCoord< 2, real > mult (const RigidCoord< 2, real > &c) const
 compute the product with another frame on the right More...
 
template<class Mat >
void writeRotationMatrix (Mat &m) const
 
template<class Mat >
void fromMatrix (const Mat &m)
 Set from the given matrix. More...
 
template<class Mat >
void toMatrix (Mat &m) const
 Write to the given matrix. More...
 
constexpr void writeOpenGlMatrix (float m[16]) const
 Write the OpenGL transformation matrix. More...
 
constexpr Vec2 vectorToChild (const Vec2 &v) const
 compute the projection of a vector from the parent frame to the child More...
 
constexpr Vec2 projectPoint (const Vec2 &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 Vec2 projectVector (const Vec2 &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 Vec2 unprojectPoint (const Vec2 &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 Vec2 unprojectVector (const Vec2 &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 Vec2 pointToParent (const Vec2 &v) const
 obsolete. Use projectPoint. More...
 
constexpr Vec2 pointToChild (const Vec2 &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< 2, real > &b) const
 
constexpr bool operator!= (const RigidCoord< 2, real > &b) const
 

Static Public Member Functions

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

Friends

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

Attribute details

◆ spatial_dimensions

template<typename real >
constexpr sofa::Size sofa::defaulttype::RigidCoord< 2, real >::spatial_dimensions = 2
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< 2, real >::total_size = 3
staticconstexpr

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

Constructor details

◆ RigidCoord() [1/2]

template<typename real >
constexpr sofa::defaulttype::RigidCoord< 2, real >::RigidCoord ( const Vec2 posCenter,
const Real orient 
)
inlineconstexpr

◆ RigidCoord() [2/2]

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

Function details

◆ clear()

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

◆ fromHomogeneous()

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

create a 2d vector from a homogeneous vector

◆ fromMatrix()

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

Set from the given matrix.

◆ getCenter() [1/2]

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

◆ getCenter() [2/2]

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

◆ getOrientation() [1/2]

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

◆ getOrientation() [2/2]

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

◆ identity()

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

◆ inverseRotate()

template<typename real >
Vec2 sofa::defaulttype::RigidCoord< 2, real >::inverseRotate ( const Vec2 v) const
inline

◆ max_size()

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

◆ mult() [1/2]

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

compute the product with another frame on the right

◆ mult() [2/2]

template<typename real >
constexpr Vec2 sofa::defaulttype::RigidCoord< 2, real >::mult ( const Vec2 v) const
inlineconstexpr

compute the product with another frame on the right

◆ multRight()

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

Apply a transformation with respect to itself.

◆ norm()

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

Euclidean norm.

◆ norm2()

template<typename real >
Real sofa::defaulttype::RigidCoord< 2, real >::norm2 ( ) const
inline

Squared norm.

◆ operator!=()

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

◆ operator*() [1/2]

template<typename real >
constexpr Real sofa::defaulttype::RigidCoord< 2, real >::operator* ( const RigidCoord< 2, 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<2, real> sofa::defaulttype::RigidCoord< 2, real >::operator* ( real2  a) const
inlineconstexpr

◆ operator*=()

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

◆ operator+() [1/2]

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

◆ operator+() [2/2]

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

◆ operator+=() [1/2]

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

◆ operator+=() [2/2]

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

◆ operator-() [1/2]

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

◆ operator-() [2/2]

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

◆ operator/()

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

◆ operator/=()

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

◆ operator==()

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

◆ operator[]() [1/2]

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

Access to i-th element.

◆ operator[]() [2/2]

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

Const access to i-th element.

◆ pointToChild()

template<typename real >
constexpr Vec2 sofa::defaulttype::RigidCoord< 2, real >::pointToChild ( const Vec2 v) const
inlineconstexpr

obsolete. Use unprojectPoint.

◆ pointToParent()

template<typename real >
constexpr Vec2 sofa::defaulttype::RigidCoord< 2, real >::pointToParent ( const Vec2 v) const
inlineconstexpr

obsolete. Use projectPoint.

◆ projectPoint()

template<typename real >
constexpr Vec2 sofa::defaulttype::RigidCoord< 2, real >::projectPoint ( const Vec2 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 Vec2 sofa::defaulttype::RigidCoord< 2, real >::projectVector ( const Vec2 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< 2, real >::ptr ( )
inlineconstexpr

◆ ptr() [2/2]

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

◆ rand()

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

Random rigid transform composed of 2 random translations and a random angle.

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

◆ rotate()

template<typename real >
Vec2 sofa::defaulttype::RigidCoord< 2, real >::rotate ( const Vec2 v) const
inline

◆ size()

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

◆ toHomogeneous()

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

create a homogeneous vector from a 2d vector

◆ toMatrix()

template<typename real >
template<class Mat >
void sofa::defaulttype::RigidCoord< 2, real >::toMatrix ( Mat m) const
inline

Write to the given matrix.

◆ translate() [1/2]

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

◆ translate() [2/2]

template<typename real >
constexpr Vec2 sofa::defaulttype::RigidCoord< 2, real >::translate ( const Vec2 v) const
inlineconstexpr

◆ unprojectPoint()

template<typename real >
constexpr Vec2 sofa::defaulttype::RigidCoord< 2, real >::unprojectPoint ( const Vec2 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 Vec2 sofa::defaulttype::RigidCoord< 2, real >::unprojectVector ( const Vec2 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)

◆ vectorToChild()

template<typename real >
constexpr Vec2 sofa::defaulttype::RigidCoord< 2, real >::vectorToChild ( const Vec2 v) const
inlineconstexpr

compute the projection of a vector from the parent frame to the child

◆ writeOpenGlMatrix()

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

Write the OpenGL transformation matrix.

◆ writeRotationMatrix()

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

Related details

◆ operator<<

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

write to an output stream

◆ operator>>

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

read from an input stream