imunano33
0.1.1
|
A minimized version of vectors for embedded devices without access to the STL (such as on an Arduino, hence the ".h" instead of ".hpp"). More...
#include <math.h>
Go to the source code of this file.
Classes | |
struct | svector::EmbVec2D |
A minimal 2D vector representation. More... | |
struct | svector::EmbVec3D |
A minimal 3D vector representation. More... | |
Functions | |
float | svector::x (const EmbVec2D &v) |
Gets the x-component of a 2D vector. More... | |
void | svector::x (EmbVec2D &v, const float xValue) |
Sets the x-component of a 2D vector. More... | |
float | svector::x (const EmbVec3D &v) |
Gets the x-component of a 3D vector. More... | |
void | svector::x (EmbVec3D &v, const float xValue) |
Sets the x-component of a 3D vector. More... | |
float | svector::y (const EmbVec2D &v) |
Gets the y-component of a 2D vector. More... | |
void | svector::y (EmbVec2D &v, const float yValue) |
Sets the y-component of a 2D vector. More... | |
float | svector::y (const EmbVec3D &v) |
Gets the y-component of a 3D vector. More... | |
void | svector::y (EmbVec3D &v, const float yValue) |
Sets the y-component of a 3D vector. More... | |
float | svector::z (const EmbVec3D &v) |
Gets the z-component of a 3D vector. More... | |
void | svector::z (EmbVec3D &v, const float zValue) |
Sets the z-component of a 3D vector. More... | |
EmbVec2D | svector::operator+ (const EmbVec2D &lhs, const EmbVec2D &rhs) |
Vector addition. More... | |
EmbVec2D | svector::operator- (const EmbVec2D &lhs, const EmbVec2D &rhs) |
Vector subtraction. More... | |
EmbVec2D | svector::operator- (const EmbVec2D &vec) |
Negative of a vector. More... | |
EmbVec2D | svector::operator+ (const EmbVec2D &vec) |
Positive of a vector. More... | |
EmbVec2D | svector::operator* (const EmbVec2D &lhs, const float rhs) |
Scalar multiplication. More... | |
EmbVec2D | svector::operator/ (const EmbVec2D &lhs, const float rhs) |
Scalar division. More... | |
bool | svector::operator== (const EmbVec2D &lhs, const EmbVec2D &rhs) |
Compares equality of two vectors. More... | |
bool | svector::operator!= (const EmbVec2D &lhs, const EmbVec2D &rhs) |
Compares inequality of two vectors. More... | |
float | svector::dot (const EmbVec2D &lhs, const EmbVec2D &rhs) |
Calculates the dot product of two vectors. More... | |
float | svector::magn (const EmbVec2D &vec) |
Gets the magnitude of the vector. More... | |
float | svector::angle (const EmbVec2D &vec) |
Gets the angle of a 2D vector in radians. More... | |
EmbVec2D | svector::normalize (const EmbVec2D &vec) |
Normalizes a vector. More... | |
bool | svector::isZero (const EmbVec2D &vec) |
Determines whether a vector is a zero vector. More... | |
EmbVec2D | svector::rotate (const EmbVec2D &vec, const float ang) |
Rotates vector by a certain angle. More... | |
EmbVec3D | svector::operator+ (const EmbVec3D &lhs, const EmbVec3D &rhs) |
Vector addition. More... | |
EmbVec3D | svector::operator- (const EmbVec3D &lhs, const EmbVec3D &rhs) |
Vector subtraction. More... | |
EmbVec3D | svector::operator- (const EmbVec3D &vec) |
Negative of a vector. More... | |
EmbVec3D | svector::operator+ (const EmbVec3D &vec) |
Positive of a vector. More... | |
EmbVec3D | svector::operator* (const EmbVec3D &lhs, const float rhs) |
Scalar multiplication. More... | |
EmbVec3D | svector::operator/ (const EmbVec3D &lhs, const float rhs) |
Scalar division. More... | |
bool | svector::operator== (const EmbVec3D &lhs, const EmbVec3D &rhs) |
Compares equality of two vectors. More... | |
bool | svector::operator!= (const EmbVec3D &lhs, const EmbVec3D &rhs) |
Compares inequality of two vectors. More... | |
float | svector::dot (const EmbVec3D &lhs, const EmbVec3D &rhs) |
Calculates the dot product of two vectors. More... | |
EmbVec3D | svector::cross (const EmbVec3D &lhs, const EmbVec3D &rhs) |
Cross product of two vectors. More... | |
float | svector::magn (const EmbVec3D &vec) |
Gets the magnitude of the vector. More... | |
EmbVec3D | svector::normalize (const EmbVec3D &vec) |
Normalizes a vector. More... | |
bool | svector::isZero (const EmbVec3D &vec) |
Determines whether a vector is a zero vector. More... | |
float | svector::alpha (const EmbVec3D &vec) |
Gets α angle. More... | |
float | svector::beta (const EmbVec3D &vec) |
Gets β angle. More... | |
float | svector::gamma (const EmbVec3D &vec) |
Gets γ angle. More... | |
EmbVec3D | svector::rotateAlpha (const EmbVec3D &vec, const float ang) |
Rotates around x-axis. More... | |
EmbVec3D | svector::rotateBeta (const EmbVec3D &vec, const float ang) |
Rotates around y-axis. More... | |
EmbVec3D | svector::rotateGamma (const EmbVec3D &vec, const float ang) |
Rotates around z-axis. More... | |
A minimized version of vectors for embedded devices without access to the STL (such as on an Arduino, hence the ".h" instead of ".hpp").
This file is meant to be a standalone file, so it is not included in vectors.hpp.
|
inline |
Gets α angle.
α is the angle between the vector and the x-axis.
vec | A 3D Vector. |
|
inline |
Gets the angle of a 2D vector in radians.
The angle will be in the range (-π, π].
vec | A 2D vector. |
|
inline |
Gets β angle.
β is the angle between the vector and the y-axis.
vec | A 3D Vector. |
Cross product of two vectors.
lhs | A 3D vector. |
rhs | A 3D vector. |
Calculates the dot product of two vectors.
lhs | First vector. |
rhs | Second vector. |
Calculates the dot product of two vectors.
lhs | First vector. |
rhs | Second vector. |
|
inline |
Gets γ angle.
γ is the angle between the vector and the z-axis.
vec | A 3D Vector. |
|
inline |
Determines whether a vector is a zero vector.
|
inline |
Determines whether a vector is a zero vector.
|
inline |
Gets the magnitude of the vector.
vec | A 2D vector. |
|
inline |
Gets the magnitude of the vector.
vec | A 3D vector. |
|
inline |
Normalizes a vector.
Finds the unit vector with the same direction angle as the current vector.
vec | A 2D vector. |
|
inline |
Normalizes a vector.
Finds the unit vector with the same direction angle as the current vector.
vec | A 3D vector. |
Compares inequality of two vectors.
lhs | The first vector. |
rhs | The second vector. |
Compares inequality of two vectors.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Scalar multiplication.
Performs scalar multiplication and returns a new vector representing the product.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Scalar multiplication.
Performs scalar multiplication and returns a new vector representing the product.
lhs | The first vector. |
rhs | The second vector. |
Vector addition.
Performs vector addition and returns a new vector representing the sum of the two vectors.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Positive of a vector.
Represents value of vector, with the unary plus operator applied to each component. In almost all cases, this should result in the original vector.
vec | A 2D vector. |
Vector addition.
Performs vector addition and returns a new vector representing the sum of the two vectors.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Positive of a vector.
Represents value of vector, with the unary plus operator applied to each component. In almost all cases, this should result in the original vector.
vec | A 3D vector. |
Vector subtraction.
Performs vector subtraction and returns a new vector representing the difference of the two vectors.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Negative of a vector.
Makes all components of a vector negative.
This can also be thought of flipping the direction of the vector.
vec | A 2D vector. |
Vector subtraction.
Performs vector subtraction and returns a new vector representing the difference of the two vectors.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Negative of a vector.
Makes all components of a vector negative of what they currently are.
This can also be thought of flipping the direction of the vector.
vec | A 3D vector. |
|
inline |
Scalar division.
Performs scalar division and returns a new vector representing the quotient.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Scalar division.
Performs scalar division and returns a new vector representing the quotient.
lhs | The first vector. |
rhs | The second vector. |
Compares equality of two vectors.
lhs | The first vector. |
rhs | The second vector. |
Compares equality of two vectors.
lhs | The first vector. |
rhs | The second vector. |
|
inline |
Rotates vector by a certain angle.
The angle should be given in radians. The vector rotates counterclockwise when the angle is positive and clockwise when the angle is negative.
vec | A 2D vector. |
ang | the angle to rotate the vector, in radians. |
|
inline |
Rotates around x-axis.
Uses the basic gimbal-like 3D rotation matrices for rotation.
vec | A 3D vector. |
ang | The angle to rotate the vector, in radians. |
|
inline |
Rotates around y-axis.
Uses the basic gimbal-like 3D rotation matrices for rotation.
vec | A 3D vector. |
ang | The angle to rotate the vector, in radians. |
|
inline |
Rotates around z-axis.
Uses the basic gimbal-like 3D rotation matrices for rotation.
vec | A 3D vector. |
ang | The angle to rotate the vector, in radians. |
|
inline |
Gets the x-component of a 2D vector.
v | A 2D Vector. |
|
inline |
Gets the x-component of a 3D vector.
v | A 3D Vector. |
|
inline |
Sets the x-component of a 2D vector.
v | A 2D Vector. |
xValue | The x-value to set to the vector. |
|
inline |
Sets the x-component of a 3D vector.
v | A 3D Vector. |
xValue | The x-value to set to the vector. |
|
inline |
Gets the y-component of a 2D vector.
v | A 2D Vector. |
|
inline |
Gets the y-component of a 3D vector.
v | A 3D Vector. |
|
inline |
Sets the y-component of a 2D vector.
v | A 2D Vector. |
yValue | The y-value to set to the vector. |
|
inline |
Sets the y-component of a 3D vector.
v | A 3D Vector. |
yValue | The y value to set to the vector. |
|
inline |
Gets the z-component of a 3D vector.
v | A 3D Vector. |
|
inline |
Sets the z-component of a 3D vector.
v | A 3D Vector. |
zValue | The z value to set to the vector. |