DD::Image::Vector4 Class Reference

Public Member Functions

float & operator[] (int i)
 
const float & operator[] (int i) const
 
const float * array () const
 
 Vector4 ()
 
 Vector4 (const float v[4])
 
 Vector4 (const double v[4])
 
 Vector4 (float a, float b, float c=0, float d=1)
 
void set (float a, float b, float c=0, float d=1)
 
 Vector4 (const Vector3 &v, float d=1)
 
void set (const Vector3 &v, float d=1)
 
Vector3 divide_w () const
 
Vector3 truncate_w () const
 
Vector4 operator* (float d) const
 
Vector4operator*= (float d)
 
Vector4 operator/ (float d) const
 
Vector4operator/= (float d)
 
Vector4 operator* (const Vector4 &v) const
 
Vector4operator*= (const Vector4 &v)
 
Vector4 operator/ (const Vector4 &v) const
 
Vector4operator/= (const Vector4 &v)
 
Vector4 operator+ (const Vector4 &v) const
 
Vector4operator+= (const Vector4 &v)
 
Vector4 operator- () const
 
Vector4 operator- (const Vector4 &v) const
 
Vector4operator-= (const Vector4 &v)
 
bool operator== (const Vector4 &v) const
 
bool operator!= (const Vector4 &v) const
 
bool operator== (float d) const
 
bool operator!= (float d) const
 
bool operator< (const Vector4 &v) const
 Fairly arbitrary operator so you can store these in ordered arrays.
 
void append (Hash &) const
 

Public Attributes

float x
 
float y
 
float z
 
float w
 

Friends

std::ostream & operator<< (std::ostream &o, const Vector4 &)
 

Detailed Description

4-component vector. This is used to represent a point in 3D homogenous (perspective) space, and is also useful to represent an rgb color with alpha.

This object is NOT compatible with the SbVec4 template in the Inventor library. Several of the operators ignore the w and treat this as a Vector3. This was done as it made use of this in the 3D system much easier.

Constructor & Destructor Documentation

DD::Image::Vector4::Vector4 ( )
inline

Default Constructor.

DD::Image::Vector4::Vector4 ( const float  v[4])
inline

Constructor from an array of numbers.

DD::Image::Vector4::Vector4 ( const double  v[4])
inline

Constructor from an array of numbers.

DD::Image::Vector4::Vector4 ( float  a,
float  b,
float  c = 0,
float  d = 1 
)
inline

Constructor that sets all 4 numbers

DD::Image::Vector4::Vector4 ( const Vector3 v,
float  d = 1 
)
inline

Conversion from a Vector3

Member Function Documentation

float& DD::Image::Vector4::operator[] ( int  i)
inline

vector[0] is x, vector[1] is y, vector[2] is z, vector[3] is w.

const float& DD::Image::Vector4::operator[] ( int  i) const
inline

vector[0] is x, vector[1] is y, vector[2] is z, vector[3] is w.

const float* DD::Image::Vector4::array ( ) const
inline

Returns a ponter that can be passed to OpenGL

Referenced by DD::Image::ParticlesSprite::draw_quad(), DD::Image::ComplexLightOp::shade_GL(), and DD::Image::LightOp::shade_GL().

void DD::Image::Vector4::set ( float  a,
float  b,
float  c = 0,
float  d = 1 
)
inline
void DD::Image::Vector4::set ( const Vector3 v,
float  d = 1 
)
inline

Conversion from a Vector3

Vector3 DD::Image::Vector4::divide_w ( ) const
inline

Divides xyz by w and returns that

Referenced by DD::Image::CameraOp::draw_handle(), and DD::Image::ViewerContext::zoom().

Vector3 DD::Image::Vector4::truncate_w ( ) const
inline

Just ignores the w. This is correct for a distance where w==0.

Vector4 DD::Image::Vector4::operator* ( float  d) const
inline

Multiplies all 4 numbers. This will multiply a distance. However if w is non-zero, the resulting 3D point will not move, because x/w will not change.

Vector4 DD::Image::Vector4::operator/ ( float  d) const
inline

Divides all 4 numbers.

Vector4 DD::Image::Vector4::operator* ( const Vector4 v) const
inline

Component-wise multiplication, useful for colors.

Vector4 DD::Image::Vector4::operator/ ( const Vector4 v) const
inline

Component-wise division, useful for colors.

Vector4 DD::Image::Vector4::operator+ ( const Vector4 v) const
inline

Component-wise addition.

Vector4 DD::Image::Vector4::operator- ( ) const
inline

Component-wise subtraction.

void Vector4::append ( Hash hash) const

Add this to the Hash object.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const Vector4  
)
friend

Writes it in nuke/tcl notation, with nested curly braces



©2020 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk