Public Member Functions | Friends | List of all members
Vec4D Class Reference

Homogenous vector for three dimensional space. More...

#include <vec4d.hpp>

Public Member Functions

 Vec4D ()
 Vec4D (double x)
 Vec4D (double x, double y)
 Vec4D (double x, double y, double z)
 Vec4D (double x, double y, double z, double w)
 Vec4D (const class Vec3D &vec)
 Vec4D (std::istream &s)
 ~Vec4D ()
double & operator[] (int i)
const double & operator[] (int i) const
double & operator() (int i)
const double & operator() (int i) const
Vec4D operator+ (const Vec4D &vec) const
 Addition.
Vec4D operator- (const Vec4D &vec) const
 Difference.
Vec4Doperator+= (const Vec4D &vec)
 Accumulation.
double operator* (const Vec4D &vec) const
 Dot product.
Vec4D operator* (double x) const
 Vector scaling.
Vec4Doperator*= (double x)
 Vector scaling.
Vec4Doperator/= (double x)
 Vector scaling with divisor.
bool operator!= (const Vec4D &x)
 Inequality test.
bool operator== (const Vec4D &x)
 Equality test.
Vec4Doperator= (const Vec4D &x)
 Assignment.
void homogenize ()
 Homogenize vector.
void normalize ()
 Normalize vector.
double norm2 () const
 Returns 2-norm of vector.
double ssqr () const
 Returns square of 2-norm of vector.
void save (std::ostream &s) const

Friends

Vec4D cross (const Vec4D &vec1, const Vec4D &vec2)
 Cross product.
double norm2 (const Vec4D &vec)
 Second norm of vector.
Vec4D operator* (double x, const Vec4D &vec)
 Vector scaling.
std::ostream & operator<< (std::ostream &os, const Vec4D &vec)
 Outputting to stream.

Detailed Description

Homogenous vector for three dimensional space.

Homogenous space has 4-vectors (x,y,z,w).

Most operations assume the arguments are either vectors (w=0) or points (w=1). These are only checked where the algorithm is dependent on this information. Otherwise the fourth coordinate (w) is assumed what the algorithm is designed for. User is responsible for calling legal operations for corrent type of vectors.

Constructor & Destructor Documentation

Vec4D::Vec4D ( )
inline
Vec4D::Vec4D ( double  x)
inline
Vec4D::Vec4D ( double  x,
double  y 
)
inline
Vec4D::Vec4D ( double  x,
double  y,
double  z 
)
inline
Vec4D::Vec4D ( double  x,
double  y,
double  z,
double  w 
)
inline
Vec4D::Vec4D ( const class Vec3D vec)
Vec4D::Vec4D ( std::istream &  s)
inline
Vec4D::~Vec4D ( )
inline

Member Function Documentation

void Vec4D::homogenize ( )
inline

Homogenize vector.

Homogenize vector by dividing all components of vector with w. Not valid for w=0.

double Vec4D::norm2 ( void  ) const
inline

Returns 2-norm of vector.

$ ||x||_2 = \sqrt{ \Sigma_{i=1}^3 x_i^2 } $

void Vec4D::normalize ( )
inline

Normalize vector.

Only valid for vector. Output is guaranteed to be a vector.

bool Vec4D::operator!= ( const Vec4D x)
inline

Inequality test.

Also tests w.

double& Vec4D::operator() ( int  i)
inline
const double& Vec4D::operator() ( int  i) const
inline
double Vec4D::operator* ( const Vec4D vec) const
inline

Dot product.

Valid for vectors only.

Vec4D Vec4D::operator* ( double  x) const
inline

Vector scaling.

Valid for points and vectors. Scaling does not affect w.

Vec4D& Vec4D::operator*= ( double  x)
inline

Vector scaling.

Valid for points and vectors. Scaling does not affect w.

Vec4D Vec4D::operator+ ( const Vec4D vec) const
inline

Addition.

Only valid for point+vector=point or vector+vector=vector. Output is of the correct type.

Vec4D& Vec4D::operator+= ( const Vec4D vec)
inline

Accumulation.

Only valid for point += vector or vector += vector. Output type does not change.

Vec4D Vec4D::operator- ( const Vec4D vec) const
inline

Difference.

Only valid for vector-vector=vector, point-vector=point or point-point=vector. Output is of the correct type.

Vec4D& Vec4D::operator/= ( double  x)
inline

Vector scaling with divisor.

Valid for points and vectors. Scaling does not affect w.

Vec4D& Vec4D::operator= ( const Vec4D x)
inline

Assignment.

bool Vec4D::operator== ( const Vec4D x)
inline

Equality test.

Also tests w.

double& Vec4D::operator[] ( int  i)
inline
const double& Vec4D::operator[] ( int  i) const
inline
void Vec4D::save ( std::ostream &  s) const
inline
double Vec4D::ssqr ( void  ) const
inline

Returns square of 2-norm of vector.

$ (||x||_2)^2 = \Sigma_{i=1}^3 x_i^2 $

Friends And Related Function Documentation

Vec4D cross ( const Vec4D vec1,
const Vec4D vec2 
)
friend

Cross product.

Only valid for vectors. Output is guaranteed to be a vector.

double norm2 ( const Vec4D vec)
friend

Second norm of vector.

Vec4D operator* ( double  x,
const Vec4D vec 
)
friend

Vector scaling.

Does not affect w.

std::ostream& operator<< ( std::ostream &  os,
const Vec4D vec 
)
friend

Outputting to stream.


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