libt3d  2.6
Public Member Functions | Public Attributes | Friends | List of all members
V3D Struct Reference

A 3D vector. More...

#include <v3d.h>

Public Member Functions

 V3D (void)
 Vector constructor. More...
 
 V3D (double x, double y, double z)
 Vector constructor. More...
 
double & operator[] (unsigned int i)
 Vector element accessor. More...
 
double & operator() (unsigned int i)
 Vector element accessor. More...
 
double & operator[] (V3DVectorIndex i)
 
V3D operator+ (const V3D &inV) const
 Sum of two vectors or of a vector and a point. More...
 
V3D operator+= (const V3D &inV)
 Sum of two vectors or of a vector and a point. More...
 
V3D operator- () const
 the opposite vector. More...
 
V3D operator- (const V3D &inV) const
 Substraction of two vectors or of a vector and a point. More...
 
V3D operator-= (const V3D &inV)
 Substraction of two vectors or of a vector and a point. More...
 
V3D operator/ (const double d) const
 Divide the vector by an double. More...
 
V3D operator/= (const double d)
 Divide the vector by an double. More...
 
V3D operator* (const double d) const
 Multiply the vector by a double. More...
 
V3D operator*= (const double d)
 Multiply the vector by a double. More...
 
double operator* (const V3D &inV) const
 dot product More...
 
V3D operator^ (const V3D &inV) const
 Vector product. More...
 
bool operator== (const V3D &inV) const
 Vector comparison. More...
 
double norm () const
 Compute euclidian norm of a V3D. More...
 
V3Dnormalize ()
 Normalize a V3D. More...
 

Public Attributes

double v [4]
 Homogeneous coordinates.
 

Friends

std::ostream & operator<< (std::ostream &os, const V3D &v3d)
 Output a ASCII V3D description to a stream. More...
 

Detailed Description

A 3D vector.

This structure manipulates vectors represented by homogeneous coordinates.

Constructor & Destructor Documentation

◆ V3D() [1/2]

V3D ( void  )
inline

Vector constructor.

Initialize a vector to all 0.

◆ V3D() [2/2]

V3D ( double  x,
double  y,
double  z 
)
inline

Vector constructor.

Initialize a vector to x,y and z.

Parameters
[in]xX coordinate.
[in]yY coordinate.
[in]zZ coordinate.

Member Function Documentation

◆ norm()

double norm ( ) const
inline

Compute euclidian norm of a V3D.

Parameters
[in]v3dInput vector
Returns
the euclidian norm of the vector.

◆ normalize()

V3D & normalize ( )
inline

Normalize a V3D.

Parameters
[in,out]v3dInput vector.
Returns
the normalized vector.

◆ operator()()

double & operator() ( unsigned int  i)
inline

Vector element accessor.

Parameters

◆ operator*() [1/2]

V3D operator* ( const double  d) const
inline

Multiply the vector by a double.

Parameters
[in]ddouble to multiply
Returns
the result of the multiplication.

◆ operator*() [2/2]

double operator* ( const V3D inV) const
inline

dot product

Parameters
[in]inVVector to multiply
Returns
the result of the dot product.

◆ operator*=()

V3D operator*= ( const double  d)
inline

Multiply the vector by a double.

Parameters
[in]ddouble to multiply
Returns
the result of the multiplication.

◆ operator+()

V3D operator+ ( const V3D inV) const
inline

Sum of two vectors or of a vector and a point.

Parameters
[in]inVVector to sum.
Returns
the result of the addition.

◆ operator+=()

V3D operator+= ( const V3D inV)
inline

Sum of two vectors or of a vector and a point.

Parameters
[in]inVVector to sum.
Returns
the result of the addition.

◆ operator-() [1/2]

V3D operator- ( ) const
inline

the opposite vector.

Returns
the opposite vector.

◆ operator-() [2/2]

V3D operator- ( const V3D inV) const
inline

Substraction of two vectors or of a vector and a point.

Parameters
[in]inVVector to substract.
Returns
the result of the substraction.

◆ operator-=()

V3D operator-= ( const V3D inV)
inline

Substraction of two vectors or of a vector and a point.

Parameters
[in]inVVector to substract.
Returns
the result of the substraction.

◆ operator/()

V3D operator/ ( const double  d) const
inline

Divide the vector by an double.

Parameters
[in]ddouble to divide
Returns
the result of the division.

◆ operator/=()

V3D operator/= ( const double  d)
inline

Divide the vector by an double.

Parameters
[in]ddouble to divide
Returns
the result of the division.

◆ operator==()

bool operator== ( const V3D inV) const
inline

Vector comparison.

Parameters
[in]inVVector to compare
Returns
the result of the comparison.

◆ operator[]() [1/2]

double & operator[] ( unsigned int  i)
inline

Vector element accessor.

Parameters
[in]iElement number.
Returns
A reference on the element value.

◆ operator[]() [2/2]

double & operator[] ( V3DVectorIndex  i)
inline

◆ operator^()

V3D operator^ ( const V3D inV) const
inline

Vector product.

Parameters
[in]inVVector to multiply
Returns
the result of the cross product.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const V3D v3d 
)
friend

Output a ASCII V3D description to a stream.

Parameters
[in]sStream to dump on.
[in]v3dV3D to dump.
Returns
reference on the output stream.