OpenSceneGraph 3.6.5
osg::Vec2f Class Reference

General purpose float pair. More...

#include <Vec2f>

Public Types

enum  { num_components = 2 }
 Number of vector components. More...
typedef float value_type
 Data type of vector components.

Public Member Functions

 Vec2f ()
 Constructor that sets all components of the vector to zero.
 Vec2f (value_type x, value_type y)
bool operator== (const Vec2f &v) const
bool operator!= (const Vec2f &v) const
bool operator< (const Vec2f &v) const
value_typeptr ()
const value_typeptr () const
void set (value_type x, value_type y)
void set (const Vec2f &rhs)
value_typeoperator[] (int i)
value_type operator[] (int i) const
value_typex ()
value_typey ()
value_type x () const
value_type y () const
bool valid () const
 Returns true if all components have values that are not NaN.
bool isNaN () const
 Returns true if at least one component has value NaN.
value_type operator* (const Vec2f &rhs) const
 Dot product.
const Vec2f operator* (value_type rhs) const
 Multiply by scalar.
Vec2foperator*= (value_type rhs)
 Unary multiply by scalar.
const Vec2f operator/ (value_type rhs) const
 Divide by scalar.
Vec2foperator/= (value_type rhs)
 Unary divide by scalar.
const Vec2f operator+ (const Vec2f &rhs) const
 Binary vector add.
Vec2foperator+= (const Vec2f &rhs)
 Unary vector add.
const Vec2f operator- (const Vec2f &rhs) const
 Binary vector subtract.
Vec2foperator-= (const Vec2f &rhs)
 Unary vector subtract.
const Vec2f operator- () const
 Negation operator.
value_type length () const
 Length of the vector = sqrt( vec .
value_type length2 (void) const
 Length squared of the vector = vec .
value_type normalize ()
 Normalize the vector so that it has length unity.

Public Attributes

value_type _v [2]
 Vec member variable.

Detailed Description

General purpose float pair.

Uses include representation of texture coordinates. No support yet added for float * Vec2f - is it necessary? Need to define a non-member non-friend operator* etc. BTW: Vec2f * float is okay

Member Typedef Documentation

◆ value_type

typedef float osg::Vec2f::value_type

Data type of vector components.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Number of vector components.

Enumerator
num_components 

Constructor & Destructor Documentation

◆ Vec2f() [1/2]

osg::Vec2f::Vec2f ( )
inline

Constructor that sets all components of the vector to zero.

References _v.

Referenced by operator!=(), operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/=(), operator<(), operator==(), and set().

◆ Vec2f() [2/2]

osg::Vec2f::Vec2f ( value_type x,
value_type y )
inline

References _v, x(), and y().

Member Function Documentation

◆ isNaN()

bool osg::Vec2f::isNaN ( ) const
inline

Returns true if at least one component has value NaN.

References _v, and osg::isNaN().

Referenced by valid().

◆ length()

value_type osg::Vec2f::length ( ) const
inline

Length of the vector = sqrt( vec .

vec )

References _v.

Referenced by normalize().

◆ length2()

value_type osg::Vec2f::length2 ( void ) const
inline

Length squared of the vector = vec .

vec

References _v.

◆ normalize()

value_type osg::Vec2f::normalize ( )
inline

Normalize the vector so that it has length unity.

Returns the previous length of the vector.

References _v, and length().

◆ operator!=()

bool osg::Vec2f::operator!= ( const Vec2f & v) const
inline

References _v, and Vec2f().

◆ operator*() [1/2]

value_type osg::Vec2f::operator* ( const Vec2f & rhs) const
inline

Dot product.

References _v, and Vec2f().

◆ operator*() [2/2]

const Vec2f osg::Vec2f::operator* ( value_type rhs) const
inline

Multiply by scalar.

References _v, and Vec2f().

◆ operator*=()

Vec2f & osg::Vec2f::operator*= ( value_type rhs)
inline

Unary multiply by scalar.

References _v, and Vec2f().

◆ operator+()

const Vec2f osg::Vec2f::operator+ ( const Vec2f & rhs) const
inline

Binary vector add.

References _v, and Vec2f().

◆ operator+=()

Vec2f & osg::Vec2f::operator+= ( const Vec2f & rhs)
inline

Unary vector add.

Slightly more efficient because no temporary intermediate object.

References _v, and Vec2f().

◆ operator-() [1/2]

const Vec2f osg::Vec2f::operator- ( ) const
inline

Negation operator.

Returns the negative of the Vec2f.

References _v, and Vec2f().

◆ operator-() [2/2]

const Vec2f osg::Vec2f::operator- ( const Vec2f & rhs) const
inline

Binary vector subtract.

References _v, and Vec2f().

◆ operator-=()

Vec2f & osg::Vec2f::operator-= ( const Vec2f & rhs)
inline

Unary vector subtract.

References _v, and Vec2f().

◆ operator/()

const Vec2f osg::Vec2f::operator/ ( value_type rhs) const
inline

Divide by scalar.

References _v, and Vec2f().

◆ operator/=()

Vec2f & osg::Vec2f::operator/= ( value_type rhs)
inline

Unary divide by scalar.

References _v, and Vec2f().

◆ operator<()

bool osg::Vec2f::operator< ( const Vec2f & v) const
inline

References _v, and Vec2f().

◆ operator==()

bool osg::Vec2f::operator== ( const Vec2f & v) const
inline

References _v, and Vec2f().

◆ operator[]() [1/2]

value_type & osg::Vec2f::operator[] ( int i)
inline

References _v.

◆ operator[]() [2/2]

value_type osg::Vec2f::operator[] ( int i) const
inline

References _v.

◆ ptr() [1/2]

value_type * osg::Vec2f::ptr ( )
inline

References _v.

◆ ptr() [2/2]

const value_type * osg::Vec2f::ptr ( ) const
inline

References _v.

◆ set() [1/2]

void osg::Vec2f::set ( const Vec2f & rhs)
inline

References _v, and Vec2f().

◆ set() [2/2]

void osg::Vec2f::set ( value_type x,
value_type y )
inline

References _v, x(), and y().

Referenced by osgText::TextBase::getCoord().

◆ valid()

bool osg::Vec2f::valid ( ) const
inline

Returns true if all components have values that are not NaN.

References isNaN().

◆ x() [1/2]

◆ x() [2/2]

value_type osg::Vec2f::x ( ) const
inline

References _v.

◆ y() [1/2]

◆ y() [2/2]

value_type osg::Vec2f::y ( ) const
inline

References _v.

Member Data Documentation

◆ _v


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

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.