Control Surface  1.2.0
MIDI Control Surface library for Arduino
Public Member Functions | Public Attributes | Related Functions | List of all members

Type for 2D vectors of floating point numbers. More...

#include <AH/Math/Vector.hpp>

+ Collaboration diagram for Vec2f:

Public Member Functions

 Vec2f ()=default
 Create a vector that is initialized to the zero vector (0,0). More...
 
 Vec2f (float x, float y)
 Create a vector with the given x and y coordinates. More...
 
Vec2foperator+= (Vec2f rhs)
 Addition. More...
 
Vec2f operator+ (Vec2f rhs) const
 Addition. More...
 
Vec2f operator- () const
 Negation. More...
 
Vec2foperator-= (Vec2f rhs)
 Subtraction. More...
 
Vec2f operator- (Vec2f rhs) const
 Subtraction. More...
 
Vec2foperator*= (float rhs)
 Scalar multiplication. More...
 
Vec2f operator* (float rhs) const
 Scalar multiplication. More...
 
Vec2foperator/= (float rhs)
 Scalar division. More...
 
Vec2f operator/ (float rhs) const
 Scalar division. More...
 
float operator* (Vec2f rhs) const
 Inner product. More...
 
float normSquared () const
 Norm squared. More...
 
float norm () const
 Norm. More...
 
Vec2fnormalize ()
 Normalize this vector. More...
 
Vec2f normalized () const
 Normalize a copy of this vector (doesn't change the original vector). More...
 
bool operator== (Vec2f rhs) const
 Equality check. More...
 
bool operator!= (Vec2f 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...
 

Related Functions

(Note that these are not member functions.)

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

Detailed Description

Type for 2D vectors of floating point numbers.

Vec2fs 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).

Definition at line 43 of file Vector.hpp.

Constructor & Destructor Documentation

◆ Vec2f() [1/2]

Vec2f ( )
default

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

◆ Vec2f() [2/2]

Vec2f ( float  x,
float  y 
)
inline

Create a vector with the given x and y coordinates.

Definition at line 50 of file Vector.hpp.

Member Function Documentation

◆ operator+=()

Vec2f& operator+= ( Vec2f  rhs)
inline

Addition.

Definition at line 53 of file Vector.hpp.

◆ operator+()

Vec2f operator+ ( Vec2f  rhs) const
inline

Addition.

Definition at line 59 of file Vector.hpp.

◆ operator-() [1/2]

Vec2f operator- ( ) const
inline

Negation.

Definition at line 66 of file Vector.hpp.

◆ operator-=()

Vec2f& operator-= ( Vec2f  rhs)
inline

Subtraction.

Definition at line 68 of file Vector.hpp.

◆ operator-() [2/2]

Vec2f operator- ( Vec2f  rhs) const
inline

Subtraction.

Definition at line 70 of file Vector.hpp.

◆ operator*=()

Vec2f& operator*= ( float  rhs)
inline

Scalar multiplication.

Definition at line 77 of file Vector.hpp.

◆ operator*() [1/2]

Vec2f operator* ( float  rhs) const
inline

Scalar multiplication.

Definition at line 83 of file Vector.hpp.

◆ operator/=()

Vec2f& operator/= ( float  rhs)
inline

Scalar division.

Definition at line 90 of file Vector.hpp.

◆ operator/()

Vec2f operator/ ( float  rhs) const
inline

Scalar division.

Definition at line 96 of file Vector.hpp.

◆ operator*() [2/2]

float operator* ( Vec2f  rhs) const
inline

Inner product.

Definition at line 103 of file Vector.hpp.

◆ normSquared()

float normSquared ( ) const
inline

Norm squared.

Definition at line 108 of file Vector.hpp.

◆ norm()

float norm ( ) const
inline

Norm.

Definition at line 110 of file Vector.hpp.

◆ normalize()

Vec2f& normalize ( )
inline

Normalize this vector.

Definition at line 115 of file Vector.hpp.

◆ normalized()

Vec2f normalized ( ) const
inline

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

Definition at line 117 of file Vector.hpp.

◆ operator==()

bool operator== ( Vec2f  rhs) const
inline

Equality check.

Definition at line 120 of file Vector.hpp.

◆ operator!=()

bool operator!= ( Vec2f  rhs) const
inline

Inequality check.

Definition at line 124 of file Vector.hpp.

Friends And Related Function Documentation

◆ operator<<()

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

Printing.

Definition at line 32 of file Vector.cpp.

Member Data Documentation

◆ x

float x = 0.0

The x component of the vector.

Definition at line 44 of file Vector.hpp.

◆ y

float y = 0.0

The y component of the vector.

Definition at line 45 of file Vector.hpp.


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