Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SbVec3f Class Reference

3D vector class. More...

#include <Inventor/SbVec.h>

+ Inheritance diagram for SbVec3f:

Public Member Functions

 SbVec3f ()
 Default constructor.
 
 SbVec3f (const float v[3])
 Constructor given vector components.
 
 SbVec3f (float x, float y, float z)
 Constructor given vector components.
 
 SbVec3f (SbPlane &p0, SbPlane &p1, SbPlane &p2)
 Constructor given 3 planes.
 
SbVec3f cross (const SbVec3f &v) const
 Returns right-handed cross product of vector and another vector.
 
float dot (const SbVec3f &v) const
 Returns dot (inner) product of vector and another vector.
 
const float * getValue () const
 Returns vector components.
 
void getValue (float &x, float &y, float &z) const
 Returns vector components.
 
float length () const
 Returns geometric length of vector.
 
float lengthSquared () const
 Returns square length of vector.
 
float normalize ()
 Changes vector to be unit length, returning the length before normalization.
 
void negate ()
 Negates each component of vector in place.
 
SbVec3fsetValue (const float v[3])
 Sets the vector components.
 
SbVec3fsetValue (float x, float y, float z)
 Sets the vector components.
 
SbVec3fsetValue (const SbVec3f &barycentic, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2)
 Sets value of vector as the weighted average of 3 other vectors.
 
SbVec3fsetValue (const SbVec3d &vec3d)
 Sets value of vector from a double precision vector.
 
float & operator[] (int i)
 Accesses indexed component of vector.
 
const float & operator[] (int i) const
 
SbVec3foperator*= (float d)
 Component-wise scalar multiplication operator.
 
SbVec3foperator/= (float d)
 Component-wise scalar division operator.
 
SbVec3foperator+= (const SbVec3f &v)
 Component-wise vector addition operator.
 
SbVec3foperator-= (const SbVec3f &v)
 Component-wise vector subtraction operator.
 
SbVec3f operator- () const
 Nondestructive unary negation - returns a new vector.
 
SbVec3f operator* (const SbVec3f &v) const
 Component-wise vector multiplication operator.
 
SbVec3foperator*= (const SbVec3f &v)
 Component-wise vector multiplication operator.
 
SbBool equals (const SbVec3f &v, float tolerance) const
 Equality comparison within given tolerance - the square of the length of the maximum distance between the two vectors.
 
SbVec3f getClosestAxis () const
 Returns principal axis that is closest (based on maximum dot product) to this vector.
 
template<typename T >
 SbVec3f (const T &v)
 Constructor that converts an arbitrary SbVec3 to an SbVec3f.
 

Friends

SbVec3f operator* (const SbVec3f &v, float d)
 Component-wise binary scalar multiplication operator.
 
SbVec3f operator* (float d, const SbVec3f &v)
 Component-wise binary scalar multiplication operator.
 
SbVec3f operator/ (const SbVec3f &v, float d)
 Component-wise binary scalar division operator.
 
SbVec3f operator+ (const SbVec3f &v1, const SbVec3f &v2)
 Component-wise binary vector addition operator.
 
SbVec3f operator- (const SbVec3f &v1, const SbVec3f &v2)
 Component-wise binary vector subtraction operator.
 
int operator== (const SbVec3f &v1, const SbVec3f &v2)
 Equality comparison operator.
 
int operator!= (const SbVec3f &v1, const SbVec3f &v2)
 Inequality comparison operator.
 
std::ostream & operator<< (std::ostream &os, const SbVec3f &v)
 Writes the vector to the specified output stream.
 

Detailed Description

3D vector class.

3D vector class used to store 3D vectors and points. This class is used throughout Open Inventor for arguments and return values.

Notes:

  • All methods that return a vector value, e.g. operator-, are creating a new SbVec3f object on every call. This is convenient but developers should keep in mind that it is also time consuming if used, for example, in a loop that calls the method many times. The methods, for example, operator-= that modify one of the objects are much more efficient when elapsed time is important.

SEE ALSO

SbRotation, SbRotationd, SbVec2d, SbVec2f, SbVec2i32, SbVec2s, SbVec3d, SbVec3i32, SbVec3s, SbVec4b, SbVec4d, SbVec4f, SbVec4i32, SbVec4s, SbVec4ub, SbVec4ui32, SbVec4us

Definition at line 932 of file SbVec.h.

Constructor & Destructor Documentation

◆ SbVec3f() [1/5]

SbVec3f::SbVec3f ( )
inline

Default constructor.

The vector is initialized with zeros.

Definition at line 937 of file SbVec.h.

◆ SbVec3f() [2/5]

SbVec3f::SbVec3f ( const float  v[3])
inlineexplicit

Constructor given vector components.

Definition at line 942 of file SbVec.h.

◆ SbVec3f() [3/5]

SbVec3f::SbVec3f ( float  x,
float  y,
float  z 
)
inline

Constructor given vector components.

Definition at line 948 of file SbVec.h.

◆ SbVec3f() [4/5]

SbVec3f::SbVec3f ( SbPlane p0,
SbPlane p1,
SbPlane p2 
)

Constructor given 3 planes.

◆ SbVec3f() [5/5]

template<typename T >
SbVec3f::SbVec3f ( const T &  v)
inlineexplicit

Constructor that converts an arbitrary SbVec3 to an SbVec3f.

Definition at line 1148 of file SbVec.h.

Member Function Documentation

◆ cross()

SbVec3f SbVec3f::cross ( const SbVec3f v) const
inline

Returns right-handed cross product of vector and another vector.

Definition at line 959 of file SbVec.h.

◆ dot()

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

Returns dot (inner) product of vector and another vector.

Definition at line 971 of file SbVec.h.

◆ equals()

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

Equality comparison within given tolerance - the square of the length of the maximum distance between the two vectors.

◆ getClosestAxis()

SbVec3f SbVec3f::getClosestAxis ( ) const

Returns principal axis that is closest (based on maximum dot product) to this vector.

◆ getValue() [1/2]

const float * SbVec3f::getValue ( ) const
inline

Returns vector components.

Definition at line 977 of file SbVec.h.

◆ getValue() [2/2]

void SbVec3f::getValue ( float &  x,
float &  y,
float &  z 
) const

Returns vector components.

◆ length()

float SbVec3f::length ( ) const

Returns geometric length of vector.

◆ lengthSquared()

float SbVec3f::lengthSquared ( ) const
inline

Returns square length of vector.

Faster than length().

Definition at line 994 of file SbVec.h.

◆ negate()

void SbVec3f::negate ( )

Negates each component of vector in place.

◆ normalize()

float SbVec3f::normalize ( )

Changes vector to be unit length, returning the length before normalization.

◆ operator*()

SbVec3f SbVec3f::operator* ( const SbVec3f v) const
inline

Component-wise vector multiplication operator.

Definition at line 1073 of file SbVec.h.

◆ operator*=() [1/2]

SbVec3f & SbVec3f::operator*= ( const SbVec3f v)
inline

Component-wise vector multiplication operator.

Definition at line 1079 of file SbVec.h.

◆ operator*=() [2/2]

SbVec3f & SbVec3f::operator*= ( float  d)

Component-wise scalar multiplication operator.

◆ operator+=()

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

Component-wise vector addition operator.

Definition at line 1050 of file SbVec.h.

◆ operator-()

SbVec3f SbVec3f::operator- ( ) const
inline

Nondestructive unary negation - returns a new vector.

Definition at line 1067 of file SbVec.h.

◆ operator-=()

SbVec3f & SbVec3f::operator-= ( const SbVec3f v)

Component-wise vector subtraction operator.

◆ operator/=()

SbVec3f & SbVec3f::operator/= ( float  d)

Component-wise scalar division operator.

◆ operator[]() [1/2]

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

Accesses indexed component of vector.

Definition at line 1033 of file SbVec.h.

◆ operator[]() [2/2]

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

Definition at line 1034 of file SbVec.h.

◆ setValue() [1/4]

SbVec3f & SbVec3f::setValue ( const float  v[3])
inline

Sets the vector components.

Definition at line 1010 of file SbVec.h.

◆ setValue() [2/4]

SbVec3f & SbVec3f::setValue ( const SbVec3d vec3d)
inline

Sets value of vector from a double precision vector.

Definition at line 1471 of file SbVec.h.

◆ setValue() [3/4]

SbVec3f & SbVec3f::setValue ( const SbVec3f barycentic,
const SbVec3f v0,
const SbVec3f v1,
const SbVec3f v2 
)

Sets value of vector as the weighted average of 3 other vectors.

◆ setValue() [4/4]

SbVec3f & SbVec3f::setValue ( float  x,
float  y,
float  z 
)
inline

Sets the vector components.

Definition at line 1016 of file SbVec.h.

Friends And Related Symbol Documentation

◆ operator!=

int operator!= ( const SbVec3f v1,
const SbVec3f v2 
)
friend

Inequality comparison operator.

Definition at line 1124 of file SbVec.h.

◆ operator* [1/2]

SbVec3f operator* ( const SbVec3f v,
float  d 
)
friend

Component-wise binary scalar multiplication operator.

Definition at line 1088 of file SbVec.h.

◆ operator* [2/2]

SbVec3f operator* ( float  d,
const SbVec3f v 
)
friend

Component-wise binary scalar multiplication operator.

Definition at line 1094 of file SbVec.h.

◆ operator+

SbVec3f operator+ ( const SbVec3f v1,
const SbVec3f v2 
)
friend

Component-wise binary vector addition operator.

Definition at line 1106 of file SbVec.h.

◆ operator-

SbVec3f operator- ( const SbVec3f v1,
const SbVec3f v2 
)
friend

Component-wise binary vector subtraction operator.

Definition at line 1112 of file SbVec.h.

◆ operator/

SbVec3f operator/ ( const SbVec3f v,
float  d 
)
friend

Component-wise binary scalar division operator.

Definition at line 1100 of file SbVec.h.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const SbVec3f v 
)
friend

Writes the vector to the specified output stream.

Definition at line 3652 of file SbVec.h.

◆ operator==

int operator== ( const SbVec3f v1,
const SbVec3f v2 
)
friend

Equality comparison operator.

Definition at line 1118 of file SbVec.h.


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