6#include "math/math_utils.h"
16 Vec3(
float x,
float y,
float z);
17 Vec3(
float* values_array);
21 Vec3 operator+(
const Vec3& other)
const;
23 Vec3 operator+(
float value)
const;
27 Vec3& operator+=(
float value);
29 Vec3 operator-(
const Vec3& other)
const;
31 Vec3 operator-(
float value)
const;
35 Vec3& operator-=(
float value);
37 bool operator==(
const Vec3& other)
const;
39 bool operator!=(
const Vec3& other)
const;
41 void operator=(
const Vec3& other);
43 void operator=(
float value);
45 Vec3 operator*(
float value)
const;
47 Vec3& operator*=(
float value);
49 Vec3 operator/(
float value)
const;
51 Vec3& operator/=(
float value);
143inline void Vec3::Normalize() { *
this /=
Magnitude(); }
148 return a.x * b.x + a.y * b.y + a.z * b.z;
156 return Vec3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z,
157 a.x * b.y - a.y * b.x);
171 return (b - a) * t + a;
175 return (b - a) * t + a;
179 return (b - a).Magnitude();
184 return direction - nn * 2 *
DotProduct(direction, nn);
188 float yaw = Radians(a.y + 90.0f);
189 float pitch = Radians(a.x);
191 forward_v.x = cosf(yaw) * cosf(pitch);
192 forward_v.y = sinf(pitch);
193 forward_v.z = sinf(yaw) * cosf(pitch);
194 forward_v.Normalize();
199 float yaw = atan2f(fron.y, fron.x);
200 float pitch = asinf(fron.z);
205 return Vec3(yaw, pitch, roll);
208inline Vec3 Vec3::operator+(
const Vec3& other)
const {
209 return Vec3(x + other.x, y + other.y, z + other.z);
212inline Vec3 Vec3::operator+(
float value)
const {
213 return Vec3(x + value, y + value, z + value);
216inline Vec3& Vec3::operator+=(
const Vec3& other) {
223inline Vec3& Vec3::operator+=(
float value) {
230inline Vec3 Vec3::operator-(
const Vec3& other)
const {
231 return Vec3(x - other.x, y - other.y, z - other.z);
234inline Vec3 Vec3::operator-(
float value)
const {
235 return Vec3(x - value, y - value, z - value);
238inline Vec3& Vec3::operator-=(
const Vec3& other) {
245inline Vec3& Vec3::operator-=(
float value) {
252inline bool Vec3::operator==(
const Vec3& other)
const {
253 if (x == other.x && y == other.y && z == other.z)
return true;
257inline bool Vec3::operator!=(
const Vec3& other)
const {
258 if (x == other.x && y == other.y && z == other.z)
return false;
262inline void Vec3::operator=(
const Vec3& other) {
268inline void Vec3::operator=(
float value) {
274inline Vec3 Vec3::operator*(
float value)
const {
275 return Vec3(x * value, y * value, z * value);
278inline Vec3& Vec3::operator*=(
float value) {
285inline Vec3 Vec3::operator/(
float value)
const {
286 return Vec3(x / value, y / value, z / value);
289inline Vec3& Vec3::operator/=(
float value) {
represents mathematical vector with 3 components
Definition: vector_3.h:12
static const Vec3 up
Vec3(0, 1, 0)
Definition: vector_3.h:117
static const Vec3 right
Vec3(1, 0, 0)
Definition: vector_3.h:121
static const Vec3 left
Vec3(-1, 0, 0)
Definition: vector_3.h:123
static Vec3 eulerToForward(const Vec3 &a)
Definition: vector_3.h:187
static const Vec3 down
Vec3(0, -1, 0)
Definition: vector_3.h:119
static float Distance(const Vec3 &a, const Vec3 &b)
Definition: vector_3.h:178
static Vec3 forwardToEuler(const Vec3 &forward, const Vec3 &up)
Definition: vector_3.h:198
static Vec3 Reflect(const Vec3 &direction, const Vec3 &normal)
Definition: vector_3.h:182
float SqrMagnitude() const
Definition: vector_3.h:160
static const Vec3 zero
Vec3(0, 0, 0)
Definition: vector_3.h:129
static float Angle(const Vec3 &a, const Vec3 &b)
Definition: vector_3.h:151
static Vec3 Lerp(const Vec3 &a, const Vec3 &b, float t)
Definition: vector_3.h:168
void Scale(const Vec3 &other)
Definition: vector_3.h:162
static const Vec3 back
Vec3(0, 0, -1)
Definition: vector_3.h:127
static Vec3 LerpUnclamped(const Vec3 &a, const Vec3 &b, float t)
Definition: vector_3.h:174
static Vec3 CrossProduct(const Vec3 &a, const Vec3 &b)
Definition: vector_3.h:155
float Magnitude() const
Definition: vector_3.h:141
static float DotProduct(const Vec3 &a, const Vec3 &b)
Definition: vector_3.h:147
static const Vec3 unit
Vec3(1, 1, 1)
Definition: vector_3.h:131
static const Vec3 forward
Vec3(0, 0, 1)
Definition: vector_3.h:125
Vec3 Normalized() const
Definition: vector_3.h:145
copperdielf Math Library
Definition: buffer.hpp:5