19#include <AH/Arduino-Wrapper.h>
20#include <AH/STL/cmath>
49 Vec2f(
float x,
float y) : x(x), y(y) {}
103 return this->x * rhs.
x + this->y * rhs.
y;
111 return std::hypot(x, y);
120 return this->x == rhs.
x && this->y == rhs.
y;
129 return {lhs * rhs.
x, lhs * rhs.
y};
151 Vec3f(
float x,
float y,
float z) : x(x), y(y), z(z) {}
153 Vec3f(
const volatile Vec3f &other) : x(other.x), y(other.y), z(other.z) {}
169 Vec3f result = *
this;
180 Vec3f result = *
this;
194 Vec3f result = *
this;
208 Vec3f result = *
this;
215 return this->x * rhs.
x + this->y * rhs.
y + this->z * rhs.
z;
223 return std::sqrt(normSquared());
234 return this->x == rhs.
x && this->y == rhs.
y && this->z == rhs.
z;
243 return {lhs * rhs.
x, lhs * rhs.
y, lhs * rhs.
z};
#define BEGIN_AH_NAMESPACE
#define AH_DIAGNOSTIC_POP()
#define AH_DIAGNOSTIC_WERROR()
Print & operator<<(Print &os, Vec3f v)
Printing.
Vec2f operator*(float lhs, Vec2f rhs)
Scalar multiplication.
Print & operator<<(Print &os, Vec2f v)
Printing.
Print & operator<<(Print &os, Quaternion e)
Printing.
Vec3f operator*(float lhs, Vec3f rhs)
Scalar multiplication.
Type for 2D vectors of floating point numbers.
float operator*(Vec2f rhs) const
Inner product.
bool operator!=(Vec2f rhs) const
Inequality check.
Vec2f operator-() const
Negation.
Vec2f normalized() const
Normalize a copy of this vector (doesn't change the original vector).
Vec2f & normalize()
Normalize this vector.
bool operator==(Vec2f rhs) const
Equality check.
Vec2f & operator*=(float rhs)
Scalar multiplication.
float normSquared() const
Norm squared.
Vec2f operator-(Vec2f rhs) const
Subtraction.
Vec2f & operator+=(Vec2f rhs)
Addition.
Vec2f operator*(float rhs) const
Scalar multiplication.
Vec2f & operator/=(float rhs)
Scalar division.
float y
The y component of the vector.
float x
The x component of the vector.
Vec2f operator+(Vec2f rhs) const
Addition.
Vec2f operator/(float rhs) const
Scalar division.
Vec2f(float x, float y)
Create a vector with the given x and y coordinates.
Vec2f & operator-=(Vec2f rhs)
Subtraction.
Vec2f()=default
Create a vector that is initialized to the zero vector (0,0).
Type for 3D vectors of floating point numbers.
Vec3f operator+(Vec3f rhs) const
Addition.
float operator*(Vec3f rhs) const
Inner product.
bool operator!=(Vec3f rhs) const
Inequality check.
Vec3f(const volatile Vec3f &other)
Vec3f operator*(float rhs) const
Scalar multiplication.
Vec3f(float x, float y, float z)
Create a vector with the given x, y and z coordinates.
void operator=(const Vec3f &other) volatile
Vec3f(const Vec3f &)=default
Vec3f operator-(Vec3f rhs) const
Subtraction.
float normSquared() const
Norm squared.
Vec3f & operator/=(float rhs)
Scalar division.
Vec3f & operator-=(Vec3f rhs)
Subtraction.
Vec3f & normalize()
Normalize this vector.
float y
The y component of the vector.
Vec3f & operator*=(float rhs)
Scalar multiplication.
Vec3f()=default
Create a vector that is initialized to the zero vector (0,0,0).
Vec3f & operator+=(Vec3f rhs)
Addition.
Vec3f operator-() const
Negation.
float x
The x component of the vector.
Vec3f operator/(float rhs) const
Scalar division.
bool operator==(Vec3f rhs) const
Equality check.
Vec3f normalized() const
Normalize a copy of this vector (doesn't change the original vector).
float z
The z component of the vector.