Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SbVec2f Class Reference

2D vector class. More...

#include <Inventor/SbVec.h>

Public Member Functions

 SbVec2f ()
 Default constructor.
 
 SbVec2f (const float v[2])
 Constructor given vector components.
 
 SbVec2f (float x, float y)
 Constructor given vector components.
 
 SbVec2f (float val)
 Constructor that sets all components to the same value.
 
float dot (const SbVec2f &v) const
 Returns dot (inner) product of vector and another vector.
 
const float * getValue () const
 Returns vector components.
 
void getValue (float &x, float &y) const
 Returns vector components.
 
float length () const
 Returns geometric length of vector.
 
float lengthSquared () const
 Returns square length of vector.
 
void negate ()
 Negates each component of vector in place.
 
float normalize ()
 Changes vector to be unit length.
 
SbVec2fsetValue (const float v[2])
 Sets the vector components.
 
SbVec2fsetValue (float x, float y)
 Sets the vector components.
 
SbVec2fsetValue (const SbVec2d &vec2d)
 Sets value of vector from a double precision vector.
 
float & operator[] (int i)
 Accesses indexed component of vector.
 
const float & operator[] (int i) const
 
SbVec2foperator*= (float d)
 Component-wise scalar multiplication operator.
 
SbVec2f operator* (const SbVec2f &v) const
 Component-wise vector multiplication operator.
 
SbVec2foperator*= (const SbVec2f &v)
 Component-wise vector multiplication operator.
 
SbVec2foperator/= (float d)
 Component-wise scalar division operator.
 
SbVec2foperator+= (const SbVec2f &u)
 Component-wise vector addition operator.
 
SbVec2foperator-= (const SbVec2f &u)
 Component-wise vector subtraction operator.
 
SbVec2f operator- () const
 Nondestructive unary negation - returns a new vector.
 
SbBool equals (const SbVec2f &v, float tolerance) const
 Equality comparison within given tolerance - the square of the length of the maximum distance between the two vectors.
 
template<typename T >
 SbVec2f (const T &v)
 Constructor that converts an arbitrary SbVec2 to an SbVec2f.
 

Friends

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

Detailed Description

2D vector class.

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

SEE ALSO

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

Definition at line 76 of file SbVec.h.

Constructor & Destructor Documentation

◆ SbVec2f() [1/5]

SbVec2f::SbVec2f ( )
inline

Default constructor.

The vector initialized with zeros.

Definition at line 82 of file SbVec.h.

◆ SbVec2f() [2/5]

SbVec2f::SbVec2f ( const float  v[2])
inlineexplicit

Constructor given vector components.

Definition at line 87 of file SbVec.h.

◆ SbVec2f() [3/5]

SbVec2f::SbVec2f ( float  x,
float  y 
)
inline

Constructor given vector components.

Definition at line 92 of file SbVec.h.

◆ SbVec2f() [4/5]

SbVec2f::SbVec2f ( float  val)
inline

Constructor that sets all components to the same value.

Definition at line 97 of file SbVec.h.

◆ SbVec2f() [5/5]

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

Constructor that converts an arbitrary SbVec2 to an SbVec2f.

Definition at line 260 of file SbVec.h.

Member Function Documentation

◆ dot()

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

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

Definition at line 102 of file SbVec.h.

◆ equals()

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

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

◆ getValue() [1/2]

const float * SbVec2f::getValue ( ) const
inline

Returns vector components.

Definition at line 108 of file SbVec.h.

◆ getValue() [2/2]

void SbVec2f::getValue ( float &  x,
float &  y 
) const

Returns vector components.

◆ length()

float SbVec2f::length ( ) const

Returns geometric length of vector.

◆ lengthSquared()

float SbVec2f::lengthSquared ( ) const
inline

Returns square length of vector.

Faster than length().

Definition at line 124 of file SbVec.h.

◆ negate()

void SbVec2f::negate ( )

Negates each component of vector in place.

◆ normalize()

float SbVec2f::normalize ( )

Changes vector to be unit length.

◆ operator*()

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

Component-wise vector multiplication operator.

Definition at line 177 of file SbVec.h.

◆ operator*=() [1/2]

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

Component-wise vector multiplication operator.

Definition at line 186 of file SbVec.h.

◆ operator*=() [2/2]

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

Component-wise scalar multiplication operator.

◆ operator+=()

SbVec2f & SbVec2f::operator+= ( const SbVec2f u)

Component-wise vector addition operator.

◆ operator-()

SbVec2f SbVec2f::operator- ( ) const

Nondestructive unary negation - returns a new vector.

◆ operator-=()

SbVec2f & SbVec2f::operator-= ( const SbVec2f u)

Component-wise vector subtraction operator.

◆ operator/=()

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

Component-wise scalar division operator.

◆ operator[]() [1/2]

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

Accesses indexed component of vector.

Definition at line 165 of file SbVec.h.

◆ operator[]() [2/2]

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

Definition at line 166 of file SbVec.h.

◆ setValue() [1/3]

SbVec2f & SbVec2f::setValue ( const float  v[2])

Sets the vector components.

◆ setValue() [2/3]

SbVec2f & SbVec2f::setValue ( const SbVec2d vec2d)

Sets value of vector from a double precision vector.

If the values stored in the double precision argument(s) are too large to be stored in single precision variables, some loss of data will occur during the data transfer. The loss of data is defined by the standard C type conversion from double to float. It is the application's responsibility to handle this potential loss of data appropriately.

NOTE: Open Inventor fields still store only single precision values, not double precision values.

◆ setValue() [3/3]

SbVec2f & SbVec2f::setValue ( float  x,
float  y 
)

Sets the vector components.

Friends And Related Symbol Documentation

◆ operator!=

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

Inequality comparison operator.

Definition at line 242 of file SbVec.h.

◆ operator* [1/2]

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

Component-wise binary scalar multiplication operator.

◆ operator* [2/2]

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

Component-wise binary scalar multiplication operator.

Definition at line 218 of file SbVec.h.

◆ operator+

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

Component-wise binary vector addition operator.

◆ operator-

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

Component-wise binary vector subtraction operator.

◆ operator/

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

Component-wise binary scalar division operator.

◆ operator<<

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

Writes the vector to the specified output stream.

Definition at line 3612 of file SbVec.h.

◆ operator==

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

Equality comparison operator.


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