SBVEC4F(3iv)

✨ SbVec4f ✨

okay bestie, welcome to the SbVec4f(3IV) manual page β€” this is the one, the icon, the 4D vector class πŸ’…


πŸ’– NAME πŸ’–

SbVec4f β€” 4D vector class πŸ¦‹


🌸 INHERITS FROM 🌸

SbVec4f β€” yes bestie, it inherits from itself, it's giving main character energy and honestly? we respect it πŸ‘‘


✨ SYNOPSIS ✨

#include <Inventor/SbLinear.h>

   Methods from class SbVec4f:

                  SbVec4f()
                  SbVec4f(const float v[4])
                  SbVec4f(float x, float y, float z, float w)
float             dot(const SbVec4f &v) const
SbBool            equals(const SbVec4f v, float tolerance) const
void              getReal(SbVec3f &v) const
const float *     getValue() const
void              getValue(float &x, float &y, float &z, float &w) const
float             length() const
void              negate()
                  normalize()
SbVec4f &         setValue(const float v[4])
SbVec4f &         setValue(float x, float y, float z, float w)
float &           operator [](int i)
const float &     operator [](int i)
SbVec4f &         operator *=(float d)
SbVec4f &         operator /=(float d)
SbVec4f &         operator +=(const SbVec4f &u)
SbVec4f &         operator -=(const SbVec4f &u)
SbVec4f           operator -() const
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)

πŸŽ€ DESCRIPTION πŸŽ€

so basically: this is a 4D vector class used to store homogeneous coordinates ✨. Like, four whole numbers, all together, living their best life.

and the way that Inventor uses it?? it's literally used in Inventor for arguments and return values β€” no cap. it's the it-girl of parameter passing, periodt πŸ’…


🧚 METHODS 🧚

🌈 Constructors 🌈

  • SbVec4f() β€” the default constructor. she's empty, she's fresh, she's ready to be filled in 🫢
  • SbVec4f(const float v[4])
  • SbVec4f(float x, float y, float z, float w)

constructor given vector components ✨ you hand over the numbers, she becomes the vector, iconic.

πŸ¦‹ dot & equals πŸ¦‹

  • float dot(const SbVec4f &v) const β€” returns the dot (inner) product of the vector and another vector. two vectors, one number, slay.
  • SbBool equals(const SbVec4f v, float tolerance) const β€” equality comparison within a given tolerance. and lowkey the important detail: the tolerance is the square of the length of the maximum distance between the two vectors. so like, it's not the distance, it's the squared distance. don't come for me, that's just what it is πŸ’€

πŸ‘‘ getReal & getValue πŸ‘‘

  • void getReal(SbVec3f &v) const β€” returns the real portion of the vector by dividing by the fourth value. yeah, dividing by w, that's the move πŸŽ€
  • const float *getValue() const
  • void getValue(float &x, float &y, float &z, float &w) const

returns vector components. either as a pointer, or handed out one by one into x, y, z, w. pick your vibe πŸ’…

🌸 length, negate, normalize 🌸

  • float length() const β€” returns the geometric length of the vector. the actual how-long-is-she number πŸ“
  • void negate() β€” negates each component of the vector in place. she changes herself, no new object, no notes.
  • normalize() β€” changes the vector to be unit length. glow-up to length one, fr fr ✨

πŸ“ setValue πŸ“

  • SbVec4f &setValue(const float v[4])
  • SbVec4f &setValue(float x, float y, float z, float w)

sets the vector components. feed her the numbers, she returns a reference so you can chain πŸ’–

πŸ’œ operator [] πŸ’œ

  • float &operator [](int i)
  • const float &operator [](int i)

accesses the indexed component of the vector. index in, component out, no drama 🎯

🌟 Compound assignment operators 🌟

  • SbVec4f &operator *=(float d)
  • SbVec4f &operator /=(float d)

component-wise scalar multiplication and division operators. every component gets the same treatment, equal rights πŸ’…

  • SbVec4f &operator +=(const SbVec4f &u)
  • SbVec4f &operator -=(const SbVec4f &u)

component-wise vector addition and subtraction operators. vector meets vector, chaos ensues, in a math way πŸ¦‹

πŸŽ€ Unary operator πŸŽ€

  • SbVec4f operator -() const β€” nondestructive unary negation β€” returns a new vector. the original stays untouched, she's protected, we love boundaries πŸ™ˆ

⭐ Binary scalar operators ⭐

  • SbVec4f operator *(const SbVec4f &v, float d)
  • SbVec4f operator *(float d, const SbVec4f &v)
  • SbVec4f operator /(const SbVec4f &v, float d)

component-wise binary scalar multiplication and division operators. note that * comes in both orders β€” v * d and d * v β€” because she's flexible like that 😌

🌈 Binary vector operators 🌈

  • SbVec4f operator +(const SbVec4f &v1, const SbVec4f &v2)
  • SbVec4f operator -(const SbVec4f &v1, const SbVec4f &v2)

component-wise binary vector addition and subtraction operators. two vectors walk in, one brand new vector walks out ✨

πŸ’€ Equality operators πŸ’€

  • int operator ==(const SbVec4f &v1, const SbVec4f &v2)
  • int operator !=(const SbVec4f &v1, const SbVec4f &v2)

equality comparison operators. returns an int, not a bool, so clock that tea β˜•


πŸ”₯ SEE ALSO πŸ”₯

SbVec2f, SbVec3f, SbVec2s, SbRotation β€” the whole friend group, go say hi 🫢


okay that's the whole page bestie, you ate it up πŸ’… and for the record, this was SbVec4f(3IV), from the SbVec4f(3IV)() era β€” that's the source/version and date situation, cute lil timestamp, iconic, no further questions πŸŽ€βœ¨