The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Vec Class Reference

#include <Vec.hpp>

Inheritance diagram for Vec:
Inheritance graph
[legend]

Public Member Functions

 Vec ()
 
 Vec (double x, double y, double z)
 
void clear ()
 
bool isNull () const
 
double norm () const
 
double norm2 () const
 
Vecoperator*= (double s)
 
Vecoperator+= (Vec v)
 
Vecoperator-= (Vec v)
 
Vecoperator/= (double s)
 
void set (double x, double y, double z)
 
double x () const
 
double y () const
 
double z () const
 

Static Public Member Functions

static Vec cross (Vec a, Vec b)
 
static double dot (Vec a, Vec b)
 

Protected Attributes

double _x
 
double _y
 
double _z
 

Detailed Description

Vec is a low-level class for working with three-dimensional vectors: each instance represents a vector with three cartesian components called x, y, and z. The class defines operators for adding two vectors and for multiplying a vector by a scalar. It offers functions to retrieve the vector components, to get the norm or the squared norm of a vector, and for calculating the dot product and cross product of two vectors. The Vec class is fully implemented inline (in this header file). Most compilers optimize away all overhead so that using this class is just as efficient as directly writing the code in terms of the vector components.

Constructor & Destructor Documentation

◆ Vec() [1/2]

Vec::Vec ( )
inline

This is the default constructor; all vector components are initialized to zero.

◆ Vec() [2/2]

Vec::Vec ( double  x,
double  y,
double  z 
)
inline

This constructor initializes the vector components to the values provided as arguments.

Member Function Documentation

◆ clear()

void Vec::clear ( )
inline

This function sets all vector components to a value of zero.

◆ cross()

static Vec Vec::cross ( Vec  a,
Vec  b 
)
inlinestatic

This static function returns the vector product (outer product) of two vectors.

◆ dot()

static double Vec::dot ( Vec  a,
Vec  b 
)
inlinestatic

This static function returns the dot product (inner product) of two vectors.

◆ isNull()

bool Vec::isNull ( ) const
inline

This function returns true if all components of the vector are trivially zero, and false otherwise.

◆ norm()

double Vec::norm ( ) const
inline

This function returns the norm of the vector.

◆ norm2()

double Vec::norm2 ( ) const
inline

This function returns the squared norm of the vector.

◆ operator*=()

Vec & Vec::operator*= ( double  s)
inline

This operator multiplies this vector by a scalar.

◆ operator+=()

Vec & Vec::operator+= ( Vec  v)
inline

This operator adds another vector to this one.

◆ operator-=()

Vec & Vec::operator-= ( Vec  v)
inline

This operator subtracts another vector from this one.

◆ operator/=()

Vec & Vec::operator/= ( double  s)
inline

This operator divides this vector by a scalar.

◆ set()

void Vec::set ( double  x,
double  y,
double  z 
)
inline

This function sets the vector components to the values provided as arguments.

◆ x()

double Vec::x ( ) const
inline

This function returns the x component of the vector.

◆ y()

double Vec::y ( ) const
inline

This function returns the y component of the vector.

◆ z()

double Vec::z ( ) const
inline

This function returns the z component of the vector.

Member Data Documentation

◆ _x

double Vec::_x
protected

These data members represent the cartesian vector components


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