sofa::defaulttype::Vec< N, real > Class Template Reference

#include <Vec.h>

Inheritance diagram for sofa::defaulttype::Vec< N, real >:

Inheritance graph
[legend]
Collaboration diagram for sofa::defaulttype::Vec< N, real >:

Collaboration graph
[legend]

Public Member Functions

 Vec ()
 Default constructor: sets all values to 0.
 Vec (NoInit)
 Fast constructor: no initialization.
 Vec (real r1)
 Specific constructor for 1-element vectors.
void operator= (real r1)
 Specific constructor for 1-element vectors.
 Vec (real r1, real r2)
 Specific constructor for 2-elements vectors.
 Vec (real r1, real r2, real r3)
 Specific constructor for 3-elements vectors.
 Vec (real r1, real r2, real r3, real r4)
 Specific constructor for 4-elements vectors.
 Vec (real r1, real r2, real r3, real r4, real r5, real r6)
 Specific constructor for 6-elements vectors.
 Vec (real r1, real r2, real r3, real r4, real r5, real r6, real r7, real r8)
 Specific constructor for 8-elements vectors.
 Vec (real r1, real r2, real r3, real r4, real r5, real r6, real r7, real r8, real r9)
 Specific constructor for 9-elements vectors.
 Vec (const Vec< N-1, real > &v, real r1)
 Constructor from an N-1 elements vector and an additional value (added at the end).
template<typename real2 >
 Vec (const Vec< N, real2 > &p)
template<typename real2 >
 Vec (const real2 *p)
 Constructor from an array of values.
real & x ()
 Special access to first element.
real & y ()
 Special access to second element.
real & z ()
 Special access to third element.
real & w ()
 Special access to fourth element.
const real & x () const
 Special const access to first element.
const real & y () const
 Special const access to second element.
const real & z () const
 Special const access to third element.
const real & w () const
 Special const access to fourth element.
template<typename real2 >
void operator= (const real2 *p)
 Assignment operator from an array of values.
template<int M, typename real2 >
void operator= (const Vec< M, real2 > &v)
 Assignment from a vector with different dimensions.
void clear ()
 Sets every element to 0.
void fill (real r)
 Sets every element to r.
real & operator() (int i)
 Const access to i-th element.
const real & operator() (int i) const
 Const access to i-th element.
const real * ptr () const
 Cast into a const array of values.
real * ptr ()
 Cast into an array of values.
template<class real2 >
Vec< N, real > operator* (real2 f) const
 Multiplication by a scalar f.
template<class real2 >
void operator*= (real2 f)
 On-place multiplication by a scalar f.
template<class real2 >
Vec< N, real > operator/ (real2 f) const
 Division by a scalar f.
template<class real2 >
void operator/= (real2 f)
 On-place division by a scalar f.
template<class real2 >
real operator* (const Vec< N, real2 > &v) const
 Dot product.
template<class real2 >
Vec< N, real > linearProduct (const Vec< N, real2 > &v) const
 linear product.
template<class real2 >
Vec< N, real > linearDivision (const Vec< N, real2 > &v) const
 linear division.
template<class real2 >
Vec< N, real > operator+ (const Vec< N, real2 > &v) const
 Vector addition.
template<class real2 >
void operator+= (const Vec< N, real2 > &v)
 On-place vector addition.
template<class real2 >
Vec< N, real > operator- (const Vec< N, real2 > &v) const
 Vector subtraction.
template<class real2 >
void operator-= (const Vec< N, real2 > &v)
 On-place vector subtraction.
Vec< N, real > operator- () const
 Vector negation.
real norm2 () const
 Squared norm.
real norm () const
 Euclidean norm.
void normalize ()
 Normalize the vector.
Vec cross (const Vec &b) const
real sum () const
 sum of all elements of the vector
Tests operators
bool operator== (const Vec &b) const
bool operator!= (const Vec &b) const

Detailed Description

template<int N, typename real = float>
class sofa::defaulttype::Vec< N, real >

Definition at line 47 of file Vec.h.


Constructor & Destructor Documentation

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec (  )  [inline]

Default constructor: sets all values to 0.

Definition at line 52 of file Vec.h.

Referenced by sofa::defaulttype::Vec< 3, float >::cross().

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( NoInit   )  [inline, explicit]

Fast constructor: no initialization.

Definition at line 58 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( real  r1  )  [inline, explicit]

Specific constructor for 1-element vectors.

Definition at line 63 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( real  r1,
real  r2 
) [inline]

Specific constructor for 2-elements vectors.

Definition at line 77 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( real  r1,
real  r2,
real  r3 
) [inline]

Specific constructor for 3-elements vectors.

Definition at line 85 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( real  r1,
real  r2,
real  r3,
real  r4 
) [inline]

Specific constructor for 4-elements vectors.

Definition at line 94 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( real  r1,
real  r2,
real  r3,
real  r4,
real  r5,
real  r6 
) [inline]

Specific constructor for 6-elements vectors.

Definition at line 104 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( real  r1,
real  r2,
real  r3,
real  r4,
real  r5,
real  r6,
real  r7,
real  r8 
) [inline]

Specific constructor for 8-elements vectors.

Definition at line 116 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( real  r1,
real  r2,
real  r3,
real  r4,
real  r5,
real  r6,
real  r7,
real  r8,
real  r9 
) [inline]

Specific constructor for 9-elements vectors.

Definition at line 130 of file Vec.h.

template<int N, typename real = float>
sofa::defaulttype::Vec< N, real >::Vec ( const Vec< N-1, real > &  v,
real  r1 
) [inline]

Constructor from an N-1 elements vector and an additional value (added at the end).

Definition at line 146 of file Vec.h.

template<int N, typename real = float>
template<typename real2 >
sofa::defaulttype::Vec< N, real >::Vec ( const Vec< N, real2 > &  p  )  [inline]

Definition at line 155 of file Vec.h.

template<int N, typename real = float>
template<typename real2 >
sofa::defaulttype::Vec< N, real >::Vec ( const real2 *  p  )  [inline, explicit]

Constructor from an array of values.

Definition at line 164 of file Vec.h.


Member Function Documentation

template<int N, typename real = float>
void sofa::defaulttype::Vec< N, real >::clear (  )  [inline]

template<int N, typename real = float>
Vec sofa::defaulttype::Vec< N, real >::cross ( const Vec< N, real > &  b  )  const [inline]

template<int N, typename real = float>
void sofa::defaulttype::Vec< N, real >::fill ( real  r  )  [inline]

Sets every element to r.

Definition at line 246 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
Vec<N,real> sofa::defaulttype::Vec< N, real >::linearDivision ( const Vec< N, real2 > &  v  )  const [inline]

linear division.

Definition at line 365 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
Vec<N,real> sofa::defaulttype::Vec< N, real >::linearProduct ( const Vec< N, real2 > &  v  )  const [inline]

template<int N, typename real = float>
real sofa::defaulttype::Vec< N, real >::norm (  )  const [inline]

Euclidean norm.

Definition at line 428 of file Vec.h.

Referenced by applyForceCallback(), sofa::helper::Quater< Real >::axisToQuat(), sofa::component::collision::NewProximityIntersection::computeIntersection(), sofa::component::collision::LocalMinDistance::computeIntersection(), sofa::helper::gl::Trackball::ComputeQuaternion(), sofa::component::topology::TriangleSetGeometryAlgorithms< DataTypes >::computeSegmentTriangleIntersection(), sofa::component::mapping::LineSetSkinningMapping< BasicMapping >::convolutionSegment(), sofa::component::collision::NewProximityIntersection::doIntersectionLineLine(), sofa::component::collision::NewProximityIntersection::doIntersectionLinePoint(), sofa::component::collision::NewProximityIntersection::doIntersectionPointPoint(), sofa::component::collision::NewProximityIntersection::doIntersectionTrianglePoint(), sofa::component::mass::UniformMass< DataTypes, MassType >::draw(), SensAble::draw(), sofa::component::topology::CylinderGridTopology::getPoint(), sofa::component::forcefield::BeamFEMForceField< DataTypes >::initLarge(), sofa::gpu::cuda::CudaRigidTypes< 3, real >::interpolate(), sofa::defaulttype::StdRigidTypes< 3, real >::interpolate(), sofa::defaulttype::Vec< 3, float >::normalize(), sofa::component::mapping::LineSetSkinningMapping< BasicMapping >::projectToSegment(), sofa::component::behaviormodel::eulerianfluid::Grid3D::seed(), sofa::component::behaviormodel::eulerianfluid::Grid2D::seed(), sofa::component::collision::Point::testLMD(), and sofa::component::collision::LocalMinDistance::testValidity().

template<int N, typename real = float>
real sofa::defaulttype::Vec< N, real >::norm2 (  )  const [inline]

template<int N, typename real = float>
void sofa::defaulttype::Vec< N, real >::normalize (  )  [inline]

Normalize the vector.

Definition at line 434 of file Vec.h.

Referenced by sofa::component::forcefield::PlaneForceField< DataTypes >::addBBox(), sofa::component::forcefield::ConicalForceField< DataTypes >::addForce(), applyForceCallback(), sofa::component::collision::DistanceGrid::calcDistance(), sofa::component::constraint::AttachConstraint< DataTypes >::calcRestRotations(), sofa::component::collision::TriangleOctreeModel::computeBoundingTree(), sofa::component::mapping::computeOrientation(), sofa::component::ParticleSink< TDataTypes >::draw(), sofa::component::collision::RigidDistanceGridCollisionModel::draw(), sofa::helper::gl::Axis::draw(), SensAble::draw(), sofa::component::forcefield::PlaneForceField< DataTypes >::drawPlane(), sofa::component::topology::CylinderGridTopology::getPoint(), sofa::component::constraint::ParabolicConstraint< DataTypes >::init(), sofa::component::forcefield::BeamFEMForceField< DataTypes >::initLarge(), sofa::gpu::cuda::CudaRigidTypes< 3, real >::interpolate(), sofa::defaulttype::StdRigidTypes< 3, real >::interpolate(), sofa::component::controller::MechanicalStateController< DataTypes >::MechanicalStateController(), sofa::gui::glut::SimpleGUI::mouseEvent(), sofa::gui::qt::viewer::qtogre::QtOgreViewer::moveRayPickInteractor(), sofa::gui::qt::viewer::qt::QtViewer::moveRayPickInteractor(), sofa::gui::qt::viewer::qgl::QtGLViewer::moveRayPickInteractor(), sofa::defaulttype::RigidCoord< 3, real >::operator+=(), sofa::component::forcefield::PlaneForceField< DataTypes >::rotate(), sofa::component::behaviormodel::eulerianfluid::Grid3D::seed(), sofa::component::behaviormodel::eulerianfluid::Grid2D::seed(), sofa::gui::qt::viewer::qt::QtViewer::StoreLightMatrices(), sofa::gui::qt::viewer::qgl::QtGLViewer::StoreLightMatrices(), sofa::gui::glut::SimpleGUI::StoreLightMatrices(), sofa::component::collision::Point::testLMD(), sofa::component::collision::LocalMinDistance::testValidity(), sofa::component::collision::RayPickInteractor::updatePosition(), sofa::component::behaviormodel::eulerianfluid::Fluid3D::updateVisual(), and sofa::component::behaviormodel::eulerianfluid::Fluid2D::updateVisual().

template<int N, typename real = float>
bool sofa::defaulttype::Vec< N, real >::operator!= ( const Vec< N, real > &  b  )  const [inline]

Definition at line 473 of file Vec.h.

template<int N, typename real = float>
const real& sofa::defaulttype::Vec< N, real >::operator() ( int  i  )  const [inline]

Const access to i-th element.

Definition at line 273 of file Vec.h.

template<int N, typename real = float>
real& sofa::defaulttype::Vec< N, real >::operator() ( int  i  )  [inline]

Const access to i-th element.

Access to i-th element.

Definition at line 267 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
real sofa::defaulttype::Vec< N, real >::operator* ( const Vec< N, real2 > &  v  )  const [inline]

Dot product.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 344 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
Vec<N,real> sofa::defaulttype::Vec< N, real >::operator* ( real2  f  )  const [inline]

Multiplication by a scalar f.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 308 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
void sofa::defaulttype::Vec< N, real >::operator*= ( real2  f  )  [inline]

On-place multiplication by a scalar f.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 318 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
Vec<N,real> sofa::defaulttype::Vec< N, real >::operator+ ( const Vec< N, real2 > &  v  )  const [inline]

Vector addition.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 375 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
void sofa::defaulttype::Vec< N, real >::operator+= ( const Vec< N, real2 > &  v  )  [inline]

On-place vector addition.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 385 of file Vec.h.

template<int N, typename real = float>
Vec<N,real> sofa::defaulttype::Vec< N, real >::operator- (  )  const [inline]

Vector negation.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 410 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
Vec<N,real> sofa::defaulttype::Vec< N, real >::operator- ( const Vec< N, real2 > &  v  )  const [inline]

Vector subtraction.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 393 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
void sofa::defaulttype::Vec< N, real >::operator-= ( const Vec< N, real2 > &  v  )  [inline]

On-place vector subtraction.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 403 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
Vec<N,real> sofa::defaulttype::Vec< N, real >::operator/ ( real2  f  )  const [inline]

Division by a scalar f.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 326 of file Vec.h.

template<int N, typename real = float>
template<class real2 >
void sofa::defaulttype::Vec< N, real >::operator/= ( real2  f  )  [inline]

On-place division by a scalar f.

Reimplemented in sofa::gpu::cuda::Vec3r1< Real >.

Definition at line 336 of file Vec.h.

template<int N, typename real = float>
template<int M, typename real2 >
void sofa::defaulttype::Vec< N, real >::operator= ( const Vec< M, real2 > &  v  )  [inline]

Assignment from a vector with different dimensions.

Reimplemented in sofa::defaulttype::VecNoInit< N, real >.

Definition at line 232 of file Vec.h.

template<int N, typename real = float>
template<typename real2 >
void sofa::defaulttype::Vec< N, real >::operator= ( const real2 *  p  )  [inline]

Assignment operator from an array of values.

Reimplemented in sofa::defaulttype::VecNoInit< N, real >.

Definition at line 223 of file Vec.h.

template<int N, typename real = float>
void sofa::defaulttype::Vec< N, real >::operator= ( real  r1  )  [inline]

Specific constructor for 1-element vectors.

Definition at line 70 of file Vec.h.

template<int N, typename real = float>
bool sofa::defaulttype::Vec< N, real >::operator== ( const Vec< N, real > &  b  )  const [inline]

Definition at line 466 of file Vec.h.

template<int N, typename real = float>
real* sofa::defaulttype::Vec< N, real >::ptr (  )  [inline]

Cast into an array of values.

Definition at line 299 of file Vec.h.

template<int N, typename real = float>
const real* sofa::defaulttype::Vec< N, real >::ptr (  )  const [inline]

template<int N, typename real = float>
real sofa::defaulttype::Vec< N, real >::sum (  )  const [inline]

sum of all elements of the vector

Definition at line 454 of file Vec.h.

Referenced by sofa::defaulttype::Vec< 3, float >::sum().

template<int N, typename real = float>
const real& sofa::defaulttype::Vec< N, real >::w (  )  const [inline]

Special const access to fourth element.

Definition at line 215 of file Vec.h.

template<int N, typename real = float>
real& sofa::defaulttype::Vec< N, real >::w (  )  [inline]

Special access to fourth element.

Definition at line 190 of file Vec.h.

template<int N, typename real = float>
const real& sofa::defaulttype::Vec< N, real >::x (  )  const [inline]

Special const access to first element.

Definition at line 197 of file Vec.h.

template<int N, typename real = float>
real& sofa::defaulttype::Vec< N, real >::x (  )  [inline]

template<int N, typename real = float>
const real& sofa::defaulttype::Vec< N, real >::y (  )  const [inline]

Special const access to second element.

Definition at line 203 of file Vec.h.

template<int N, typename real = float>
real& sofa::defaulttype::Vec< N, real >::y (  )  [inline]

template<int N, typename real = float>
const real& sofa::defaulttype::Vec< N, real >::z (  )  const [inline]

Special const access to third element.

Definition at line 209 of file Vec.h.

template<int N, typename real = float>
real& sofa::defaulttype::Vec< N, real >::z (  )  [inline]


The documentation for this class was generated from the following file:

Generated on Sun Nov 23 04:23:55 2008 for Sofa by  doxygen 1.5.7.1