ML Reference
ml::Tvec3< DT > Class Template Reference

Forward declarations to resolve header file dependencies. More...

#include <mlVector3.h>

Inheritance diagram for ml::Tvec3< DT >:
ml::FloatingPointVector< DT, 3, Vector3DataContainer< DT > > ml::Vector3DataContainer< DT >

Public Types

typedef FloatingPointVector< DT, 3, Vector3DataContainer< DT > > Superclass
 A typedef as a shorthand for the base class.
typedef DT ComponentType
 A typedef to 'export' the type of components.
Public Types inherited from ml::FloatingPointVector< DT, 3, Vector3DataContainer< DT > >
enum  
typedef DT ComponentType
 A typedef to 'export' the type of components.

Public Member Functions

void assign (const DT px, const DT py, const DT pz)
 Sets all components to the passed values.
Tvec3< DT > divideByLastComp () const
Tvec4< DT > affineVec () const
Tvec4< DT > affinePoint () const
Constructors
 Tvec3 (const DT value=0)
 Tvec3 (const Superclass &v)
 Tvec3 (const DT px, const DT py, const DT pz)
 Constructor building the vector px, py, and pz.
 Tvec3 (const Tvec2< DT > &v, const DT pz)
 Builds a Tvec3 from a Tvec2 and a scalar. Sets the third entry to user given value pz.
 Tvec3 (const Tvec4< DT > &v, const bool normalizeV)
 Tvec3 (const Tvec4< DT > &v, const int axis)
Public Member Functions inherited from ml::FloatingPointVector< DT, 3, Vector3DataContainer< DT > >
 FloatingPointVector (DT value=DT(0))
FloatingPointVector< DT, size, Vector3DataContainer< DT > > & operator= (DT value)
 Assignment of scalar value to all components.
bool operator== (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &buffer) const
 Returns whether *this and buffer are component-wise equal.
bool operator!= (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &buffer) const
 Returns whether any components of *this and buffer are not equal.
bool operator< (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &buffer) const
const DT & operator[] (const size_t i) const
DT & operator[] (const size_t i)
size_t getSize () const
 Returns the number of elements of value buffer.
DT norm2 () const
DT norm2 (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &weight) const
DT dot (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &buffer) const
DT normalize ()
DT length () const
 Returns the length of the vector, i.e., norm2().
DT distance (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &buffer) const
 Returns the distance of this vector to a given one.
DT distanceSquared (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &buffer) const
 Returns the squared distance of this vector to a given one.
DT lengthSquared () const
 Returns the squared length of the vector.
DT compSum () const
 Returns the sum of all components.
DT compMul () const
 Returns the product of all vector components.
DT compMaxAbs () const
 Returns the maximum of absolute component values.
void compMin (FloatingPointVector< DT, size, Vector3DataContainer< DT > > buffer)
 Sets the component-wise minimum of *this and buffer in *this.
void compMax (FloatingPointVector< DT, size, Vector3DataContainer< DT > > buffer)
 Sets the component-wise maximum of *this and buffer in *this.
void compAbs ()
 Kills negative signs from all components.
void compDiv (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &d)
void compSqr ()
 Calculates and sets the square of all components.
void compSqrt ()
void clampMin (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &lower)
void clampMax (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &upper)
void clamp (const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &lower, const FloatingPointVector< DT, size, Vector3DataContainer< DT > > &upper)
void compRound ()
 Rounds all components of this vector using floor(component + 0.5).
void compFloor ()
 Rounds all components of this vector using floor(component).
void compCeil ()
 Rounds all components of this vector to integer using ceil(component).
FloatingPointVector< DT, 3, Vector3DataContainer< DT > > cross (const FloatingPointVector< DT, 3, Vector3DataContainer< DT > > &b) const
 Returns the cross product for elements, i.e., the returned vector is orthogonal to *this and b.
void apply (ML_LA_FROM_DOUBLE_TO_DOUBLE f)
 Applies the function f to each component starting from index 0 to index size-1.
std::ostream & writeOut (std::ostream &os) const
std::istream & readIn (std::istream &is)
 Reads all components from istream is starting starting from index 0 to size-1.

Additional Inherited Members

Public Attributes inherited from ml::Vector3DataContainer< DT >
union { 
   struct { 
      DT   x 
 X-component of the vector, same as _buffer[0]. More...
      DT   y 
 Y-component of the vector, same as _buffer[1]. More...
      DT   z 
 Z-component of the vector, same as _buffer[2]. More...
   } 
   DT   _buffer [3] 
 Data members as vector to provide array access, same as x, y, and z members. More...
}; 

Detailed Description

template<class DT>
class ml::Tvec3< DT >

Forward declarations to resolve header file dependencies.

A three dimensional vector class for floating point types.

Definition at line 65 of file mlVector3.h.

Member Typedef Documentation

◆ ComponentType

template<class DT>
typedef DT ml::Tvec3< DT >::ComponentType

A typedef to 'export' the type of components.

Definition at line 74 of file mlVector3.h.

◆ Superclass

template<class DT>
typedef FloatingPointVector<DT, 3, Vector3DataContainer<DT> > ml::Tvec3< DT >::Superclass

A typedef as a shorthand for the base class.

Definition at line 71 of file mlVector3.h.

Constructor & Destructor Documentation

◆ Tvec3() [1/6]

template<class DT>
ml::Tvec3< DT >::Tvec3 ( const DT value = 0)
inlineexplicit

Default and value constructor. Sets all entries to a user given value. value is the init value for all entries. 0 is the default value.

Definition at line 82 of file mlVector3.h.

◆ Tvec3() [2/6]

template<class DT>
ml::Tvec3< DT >::Tvec3 ( const Superclass & v)
inline

Copy constructor from FloatingPointVector. This allows the usage of SclarVectorTemplate objects of the same DT in operators using the Tvec3, because the FloatingPointVector objects can implicitly be cast.

Definition at line 89 of file mlVector3.h.

◆ Tvec3() [3/6]

template<class DT>
ml::Tvec3< DT >::Tvec3 ( const DT px,
const DT py,
const DT pz )
inline

Constructor building the vector px, py, and pz.

Definition at line 94 of file mlVector3.h.

◆ Tvec3() [4/6]

template<class DT>
ml::Tvec3< DT >::Tvec3 ( const Tvec2< DT > & v,
const DT pz )
inline

Builds a Tvec3 from a Tvec2 and a scalar. Sets the third entry to user given value pz.

Definition at line 102 of file mlVector3.h.

◆ Tvec3() [5/6]

template<class DT>
ml::Tvec3< DT >::Tvec3 ( const Tvec4< DT > & v,
const bool normalizeV )
inline

Casts a Tvec4 v to Tvec3. If normalize is true, then the first three components are divided by the last one to implement a homogeneous cast. In that case, it is up to the caller to avoid a division by zero. If normalize is false, then the first three components are taken unchanged.

Definition at line 114 of file mlVector3.h.

◆ Tvec3() [6/6]

template<class DT>
ml::Tvec3< DT >::Tvec3 ( const Tvec4< DT > & v,
const int axis )
inline

Casts a Tvec4 v to Tvec3. axis specifies component to be thrown away. All other components are copied sequentially. If axis is not within [0,3], then the last component is thrown away.

Definition at line 143 of file mlVector3.h.

Member Function Documentation

◆ affinePoint()

template<class DT>
Tvec4< DT > ml::Tvec3< DT >::affinePoint ( ) const
inline

Builds a homogeneous Tvec4 point from *this and returns it, i.e., leaves all components unchanged and sets the fourth component to 1.

Definition at line 203 of file mlVector3.h.

Referenced by ml::operator*(), and ml::Tmat4< MLfloat >::transformPoint().

◆ affineVec()

template<class DT>
Tvec4< DT > ml::Tvec3< DT >::affineVec ( ) const
inline

Builds a homogeneous Tvec4 vector from *this and returns it, i.e., leaves all components unchanged and sets the fourth component to 0.

Definition at line 196 of file mlVector3.h.

◆ assign()

template<class DT>
void ml::Tvec3< DT >::assign ( const DT px,
const DT py,
const DT pz )
inline

Sets all components to the passed values.

Definition at line 171 of file mlVector3.h.

◆ divideByLastComp()

template<class DT>
Tvec3< DT > ml::Tvec3< DT >::divideByLastComp ( ) const
inline

Divides all vector components by its last component and returns it as Tvec3, which then has a 1 as last component. It is useful to scale the vector from homogeneous space to normal space. It is up to the caller to avoid a division by zero if last component is 0.

Definition at line 182 of file mlVector3.h.


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