Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SbVec4f Class Reference

The SbVec4f class is a 4 dimensional vector with floating point coordinates. More...

#include <Inventor/SbVec4f.h>

Inheritance diagram for SbVec4f:
SbColor4f

Public Member Functions

 SbVec4f (void)
 
 SbVec4f (const float v[4])
 
 SbVec4f (float x, float y, float z, float w)
 
 SbVec4f (const SbVec4d &v)
 
 SbVec4f (const SbVec4b &v)
 
 SbVec4f (const SbVec4s &v)
 
 SbVec4f (const SbVec4i32 &v)
 
SbVec4fsetValue (const float v[4])
 
SbVec4fsetValue (float x, float y, float z, float w)
 
SbVec4fsetValue (const SbVec4d &v)
 
SbVec4fsetValue (const SbVec4b &v)
 
SbVec4fsetValue (const SbVec4s &v)
 
SbVec4fsetValue (const SbVec4i32 &v)
 
const float * getValue (void) const
 
void getValue (float &x, float &y, float &z, float &w) const
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
SbBool equals (const SbVec4f &v, float tolerance) const
 
float dot (const SbVec4f &v) const
 
void getReal (SbVec3f &v) const
 
float length (void) const
 
float sqrLength (void) const
 
void negate (void)
 
float normalize (void)
 
SbVec4foperator*= (float d)
 
SbVec4foperator/= (float d)
 
SbVec4foperator+= (const SbVec4f &v)
 
SbVec4foperator-= (const SbVec4f &v)
 
SbVec4f operator- (void) const
 
void print (FILE *fp) const
 

Protected Attributes

float vec [4]
 

Related Functions

(Note that these are not member functions.)

SbVec4f operator* (const SbVec4f &v, float d)
 
SbVec4f operator* (float d, const SbVec4f &v)
 
SbVec4f operator/ (const SbVec4f &v, float d)
 
SbVec4f operator+ (const SbVec4f &v1, const SbVec4f &v2)
 
SbVec4f operator- (const SbVec4f &v1, const SbVec4f &v2)
 
int operator== (const SbVec4f &v1, const SbVec4f &v2)
 
int operator!= (const SbVec4f &v1, const SbVec4f &v2)
 

Detailed Description

The SbVec4f class is a 4 dimensional vector with floating point coordinates.

This vector class is used by many other classes in Coin. It provides storage for a 3 dimensional homogeneoues vector (with the 4 components usually referred to as <x, y, z, w>) as well as simple floating point arithmetic operations.

See also
SbVec2s, SbVec2f, SbVec2d, SbVec3s, SbVec3f, SbVec3d, SbVec4d.

Constructor & Destructor Documentation

◆ SbVec4f() [1/7]

SbVec4f::SbVec4f ( void  )
inline

The default constructor does nothing. The vector coordinates will be uninitialized until a call the setValue().

◆ SbVec4f() [2/7]

SbVec4f::SbVec4f ( const float  v[4])
inline

Constructs an SbVec4f instance with initial values from v.

◆ SbVec4f() [3/7]

SbVec4f::SbVec4f ( float  x,
float  y,
float  z,
float  w 
)
inline

Constructs an SbVec4f instance with the initial homogeneous vector set to <x,y,z,w>.

◆ SbVec4f() [4/7]

SbVec4f::SbVec4f ( const SbVec4d v)
inlineexplicit

Constructs an SbVec4f instance from an SbVec4d instance.

◆ SbVec4f() [5/7]

SbVec4f::SbVec4f ( const SbVec4b v)
inlineexplicit

Constructs an SbVec4f instance from an SbVec4b instance.

Since
Coin 2.5

◆ SbVec4f() [6/7]

SbVec4f::SbVec4f ( const SbVec4s v)
inlineexplicit

Constructs an SbVec4f instance from an SbVec4s instance.

Since
Coin 2.5

◆ SbVec4f() [7/7]

SbVec4f::SbVec4f ( const SbVec4i32 v)
inlineexplicit

Constructs an SbVec4f instance from an SbVec4i32 instance.

Since
Coin 2.5

Member Function Documentation

◆ setValue() [1/6]

SbVec4f & SbVec4f::setValue ( const float  v[4])
inline

Set new coordinates for the vector from v. Returns reference to self.

See also
getValue().

◆ setValue() [2/6]

SbVec4f & SbVec4f::setValue ( float  x,
float  y,
float  z,
float  w 
)
inline

Set new coordinates for the vector. Returns reference to self.

See also
getValue().

◆ setValue() [3/6]

SbVec4f & SbVec4f::setValue ( const SbVec4d v)

Sets the value from an SbVec4d instance.

◆ setValue() [4/6]

SbVec4f & SbVec4f::setValue ( const SbVec4b v)
Since
Coin 2.5

◆ setValue() [5/6]

SbVec4f & SbVec4f::setValue ( const SbVec4s v)
Since
Coin 2.5

◆ setValue() [6/6]

SbVec4f & SbVec4f::setValue ( const SbVec4i32 v)
Since
Coin 2.5

◆ getValue() [1/2]

const float * SbVec4f::getValue ( void  ) const
inline

Returns a pointer to an array of four floats containing the x, y, z and w coordinates of the vector.

See also
setValue().

◆ getValue() [2/2]

void SbVec4f::getValue ( float &  x,
float &  y,
float &  z,
float &  w 
) const
inline

Returns the x, y, z and w coordinates of the vector.

See also
setValue().

◆ operator[]() [1/2]

float & SbVec4f::operator[] ( int  i)
inline

Index operator. Returns modifiable x, y, z or w component of vector.

See also
getValue() and setValue().

◆ operator[]() [2/2]

const float & SbVec4f::operator[] ( int  i) const
inline

Index operator. Returns x, y, z or w component of vector.

See also
getValue() and setValue().

◆ equals()

SbBool SbVec4f::equals ( const SbVec4f v,
float  tolerance 
) const

Compares the vector with v and returns TRUE if the distance between the vectors is smaller or equal to the square root of tolerance.

The comparison is done in 4D-space, i.e. the w component of the vector is not used to make x, y and z into Cartesian coordinates first.

◆ dot()

float SbVec4f::dot ( const SbVec4f v) const
inline

Calculates and returns the result of taking the dot product of this vector and v.

◆ getReal()

void SbVec4f::getReal ( SbVec3f v) const

Returns the vector as a Cartesian 3D vector in v. This means that the 3 first components x, y and z will be divided by the fourth, w.

◆ length()

float SbVec4f::length ( void  ) const

Return the length of the vector in 4D space.

◆ sqrLength()

float SbVec4f::sqrLength ( void  ) const
inline

Return the square of the length of the vector in 4D space.

◆ negate()

void SbVec4f::negate ( void  )
inline

Negate the vector.

◆ normalize()

float SbVec4f::normalize ( void  )

Normalize the vector to unit length. Return value is the original length of the vector before normalization.

◆ operator*=()

SbVec4f & SbVec4f::operator*= ( float  d)
inline

Multiply components of vector with value d. Returns reference to self.

◆ operator/=()

SbVec4f & SbVec4f::operator/= ( float  d)
inline

Divides components of vector with value d. Returns reference to self.

◆ operator+=()

SbVec4f & SbVec4f::operator+= ( const SbVec4f v)
inline

Adds this vector and vector v. Returns reference to self.

◆ operator-=()

SbVec4f & SbVec4f::operator-= ( const SbVec4f v)
inline

Subtracts vector v from this vector. Returns reference to self.

◆ operator-()

SbVec4f SbVec4f::operator- ( void  ) const
inline

Non-destructive negation operator. Returns a new SbVec4f instance which has all components negated.

See also
negate().

◆ print()

void SbVec4f::print ( FILE *  fp) const

Dump the state of this object to the file stream. Only works in debug version of library, method does nothing in an optimized compile.

Friends And Related Function Documentation

◆ operator*() [1/2]

SbVec4f operator* ( const SbVec4f v,
float  d 
)
related

Returns an SbVec4f instance which is the components of vector v multiplied with d.

◆ operator*() [2/2]

SbVec4f operator* ( float  d,
const SbVec4f v 
)
related

Returns an SbVec4f instance which is the components of vector v multiplied with d.

◆ operator/()

SbVec4f operator/ ( const SbVec4f v,
float  d 
)
related

Returns an SbVec4f instance which is the components of vector v divided on the scalar factor d.

◆ operator+()

SbVec4f operator+ ( const SbVec4f v1,
const SbVec4f v2 
)
related

Returns an SbVec4f instance which is the sum of vectors v1 and v2.

◆ operator-()

SbVec4f operator- ( const SbVec4f v1,
const SbVec4f v2 
)
related

Returns an SbVec4f instance which is vector v2 subtracted from vector v1.

◆ operator==()

int operator== ( const SbVec4f v1,
const SbVec4f v2 
)
related

Returns 1 if v1 and v2 are equal, 0 otherwise.

See also
equals().

◆ operator!=()

int operator!= ( const SbVec4f v1,
const SbVec4f v2 
)
related

Returns 1 if v1 and v2 are not equal, 0 if they are equal.

See also
equals().

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