mirror of
https://github.com/thunderbrewhq/typhoon.git
synced 2025-12-12 10:32:29 +00:00
feat(vector): update C2Vector class
This commit is contained in:
parent
8e406788b1
commit
f28f744a5b
5 changed files with 248 additions and 2 deletions
|
|
@ -1,17 +1,63 @@
|
|||
#ifndef TEMPEST_VECTOR_C_2VECTOR_HPP
|
||||
#define TEMPEST_VECTOR_C_2VECTOR_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class C2Vector {
|
||||
public:
|
||||
// Member variables
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
|
||||
enum : uint32_t {
|
||||
eComponents = 2
|
||||
};
|
||||
|
||||
// Static functions
|
||||
static C2Vector FromAxisAngle(float axang, float mag);
|
||||
static C2Vector Min(const C2Vector& a, const C2Vector& b);
|
||||
static C2Vector Max(const C2Vector& a, const C2Vector& b);
|
||||
static C2Vector Lerp(const C2Vector& a, const C2Vector& l, const C2Vector& h);
|
||||
static float Dot(const C2Vector& l, const C2Vector& r);
|
||||
static float Cross(const C2Vector& l, const C2Vector& r);
|
||||
|
||||
|
||||
// Member functions
|
||||
C2Vector() = default;
|
||||
C2Vector(float x, float y)
|
||||
: x(x)
|
||||
, y(y) {};
|
||||
C2Vector(float a)
|
||||
: x(a)
|
||||
, y(a) {};
|
||||
|
||||
void Get(float& ox, float& oy) const;
|
||||
void Set(float nx, float ny);
|
||||
|
||||
C2Vector& operator+=(float a);
|
||||
C2Vector& operator+=(const C2Vector& a);
|
||||
C2Vector& operator-=(float a);
|
||||
C2Vector& operator-=(const C2Vector& a);
|
||||
C2Vector& operator*=(float a);
|
||||
C2Vector& operator*=(const C2Vector& a);
|
||||
C2Vector& operator/=(float a);
|
||||
C2Vector& operator/=(const C2Vector& a);
|
||||
|
||||
C2Vector operator-();
|
||||
|
||||
float& operator[](uint32_t sub);
|
||||
const float& operator[](uint32_t sub) const;
|
||||
|
||||
float SquaredMag() const;
|
||||
float Mag() const;
|
||||
float SumC() const;
|
||||
bool IsUnit() const;
|
||||
float AxisAngle() const;
|
||||
float AxisAngle(float mag) const;
|
||||
|
||||
void Normalize();
|
||||
void Scale(float a);
|
||||
|
||||
bool operator==(const C2Vector& v);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue