Arduino Helpers master
Utility library for Arduino
Public Member Functions | Public Attributes | Related Functions | List of all members
Vec3f Struct Reference

#include <AH/Math/Vector.hpp>

Detailed Description

Type for 3D vectors of floating point numbers.

Vec3fs can be added, subtracted, multiplied (dot product) and normalized. It also has an implementation of the following operators: "+", "+=", "-", "-=", "*" (vector-vector); "*", "*=", "/", "/=" (vector-scalar); "==", "!=" (equality); "*" (scalar-vector); "<<" (printing).

Examples
Quaternion.ino.

Definition at line 140 of file Vector.hpp.

+ Collaboration diagram for Vec3f:

Public Member Functions

 Vec3f ()=default
 Create a vector that is initialized to the zero vector (0,0,0). More...
 
 Vec3f (float x, float y, float z)
 Create a vector with the given x, y and z coordinates. More...
 
 Vec3f (const Vec3f &)=default
 
 Vec3f (const volatile Vec3f &other)
 
void operator= (const Vec3f &other) volatile
 
Vec3foperator+= (Vec3f rhs)
 Addition. More...
 
Vec3f operator+ (Vec3f rhs) const
 Addition. More...
 
Vec3f operator- () const
 Negation. More...
 
Vec3foperator-= (Vec3f rhs)
 Subtraction. More...
 
Vec3f operator- (Vec3f rhs) const
 Subtraction. More...
 
Vec3foperator*= (float rhs)
 Scalar multiplication. More...
 
Vec3f operator* (float rhs) const
 Scalar multiplication. More...
 
Vec3foperator/= (float rhs)
 Scalar division. More...
 
Vec3f operator/ (float rhs) const
 Scalar division. More...
 
float operator* (Vec3f rhs) const
 Inner product. More...
 
float normSquared () const
 Norm squared. More...
 
float norm () const
 Norm. More...
 
Vec3fnormalize ()
 Normalize this vector. More...
 
Vec3f normalized () const
 Normalize a copy of this vector (doesn't change the original vector). More...
 
bool operator== (Vec3f rhs) const
 Equality check. More...
 
bool operator!= (Vec3f rhs) const
 Inequality check. More...
 

Public Attributes

float x = 0.0
 The x component of the vector. More...
 
float y = 0.0
 The y component of the vector. More...
 
float z = 0.0
 The z component of the vector. More...
 

Related Functions

(Note that these are not member functions.)

Print & operator<< (Print &os, Vec3f v)
 Printing. More...
 
Vec3f operator* (float lhs, Vec3f rhs)
 Scalar multiplication. More...
 
Print & operator<< (Print &os, Vec3f v)
 Printing. More...
 

Constructor & Destructor Documentation

◆ Vec3f() [1/4]

Vec3f ( )
default

Create a vector that is initialized to the zero vector (0,0,0).

◆ Vec3f() [2/4]

Vec3f ( float  x,
float  y,
float  z 
)
inline

Create a vector with the given x, y and z coordinates.

Definition at line 148 of file Vector.hpp.

◆ Vec3f() [3/4]

Vec3f ( const Vec3f )
default

◆ Vec3f() [4/4]

Vec3f ( const volatile Vec3f other)
inline

Definition at line 150 of file Vector.hpp.

Member Function Documentation

◆ operator=()

void operator= ( const Vec3f other) volatile
inline

Definition at line 151 of file Vector.hpp.

◆ operator+=()

Vec3f & operator+= ( Vec3f  rhs)
inline

Addition.

Definition at line 158 of file Vector.hpp.

◆ operator+()

Vec3f operator+ ( Vec3f  rhs) const
inline

Addition.

Definition at line 165 of file Vector.hpp.

◆ operator-() [1/2]

Vec3f operator- ( ) const
inline

Negation.

Definition at line 172 of file Vector.hpp.

◆ operator-=()

Vec3f & operator-= ( Vec3f  rhs)
inline

Subtraction.

Definition at line 174 of file Vector.hpp.

◆ operator-() [2/2]

Vec3f operator- ( Vec3f  rhs) const
inline

Subtraction.

Definition at line 176 of file Vector.hpp.

◆ operator*=()

Vec3f & operator*= ( float  rhs)
inline

Scalar multiplication.

Definition at line 183 of file Vector.hpp.

◆ operator*() [1/2]

Vec3f operator* ( float  rhs) const
inline

Scalar multiplication.

Definition at line 190 of file Vector.hpp.

◆ operator/=()

Vec3f & operator/= ( float  rhs)
inline

Scalar division.

Definition at line 197 of file Vector.hpp.

◆ operator/()

Vec3f operator/ ( float  rhs) const
inline

Scalar division.

Definition at line 204 of file Vector.hpp.

◆ operator*() [2/2]

float operator* ( Vec3f  rhs) const
inline

Inner product.

Definition at line 211 of file Vector.hpp.

◆ normSquared()

float normSquared ( ) const
inline

Norm squared.

Definition at line 216 of file Vector.hpp.

◆ norm()

float norm ( ) const
inline

Norm.

Examples
Quaternion.ino.

Definition at line 219 of file Vector.hpp.

◆ normalize()

Vec3f & normalize ( )
inline

Normalize this vector.

Definition at line 225 of file Vector.hpp.

◆ normalized()

Vec3f normalized ( ) const
inline

Normalize a copy of this vector (doesn't change the original vector).

Examples
Quaternion.ino.

Definition at line 227 of file Vector.hpp.

◆ operator==()

bool operator== ( Vec3f  rhs) const
inline

Equality check.

Definition at line 230 of file Vector.hpp.

◆ operator!=()

bool operator!= ( Vec3f  rhs) const
inline

Inequality check.

Definition at line 234 of file Vector.hpp.

Friends And Related Function Documentation

◆ operator<<()

Print & operator<< ( Print &  os,
Vec3f  v 
)
related

Printing.

Member Data Documentation

◆ x

float x = 0.0

The x component of the vector.

Definition at line 141 of file Vector.hpp.

◆ y

float y = 0.0

The y component of the vector.

Definition at line 142 of file Vector.hpp.

◆ z

float z = 0.0

The z component of the vector.

Definition at line 143 of file Vector.hpp.


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