#ifndef VECTOR_H #define VECTOR_H #pragma once struct Quaternion; extern "C" { typedef struct Vec3 { float x; float y; float z; } Vec3; void CopyVec3(const Vec3& v1, Vec3& v2); } /// /// A 3-dimensional vector /// struct Vector3 : Vec3 { public: /// /// Create a new 3-dimensinal zero vector /// Vector3(); /// /// Create a new 3-dimensional vector /// /// x axis value /// y axis value /// z axis value Vector3(float x, float y, float z); /// /// Create a vector from C-style Vec3 /// /// The C-style Vec Vector3(Vec3 v); ~Vector3(); /// /// A vector with zero for all axis /// const static Vector3 zero; /// /// A vector with values (1, 0, 0) /// const static Vector3 right; /// /// A vector3 with values (-1, 0, 0) /// const static Vector3 left; /// /// A vector with values (0, 1, 0) /// const static Vector3 up; /// /// A vector with values (0, -1, 0) /// const static Vector3 down; /// /// A vector with values (0, 0, 1) /// const static Vector3 forward; /// /// A vector with values (0, 0, -1) /// const static Vector3 back; static float Magnitude(const Vector3& a); float magnitude() const; static float SqrMagnitude(const Vector3& a); float sqrMagnitude() const; static Vector3 Normalize(Vector3 v); Vector3 normalized() const; Vector3 operator -(); Vector3 operator -(const Vector3& p2) const; Vector3 operator +(const Vector3& t1) const; static Vector3 Scale(const Vector3& p1, const Vector3& p2); Vector3 operator *(float f) const; Vector3 operator /(const float& d); static float Dot(const Vector3& v1, const Vector3& v2); bool operator ==(const Vector3& v); static float Distance(const Vector3& p1, const Vector3& p2); static Vector3 Cross(const Vector3& v1, const Vector3& v2); // Projects a vector onto another vector. static Vector3 Project(Vector3 vector, Vector3 onNormal); // Projects a vector onto a plane defined by a normal orthogonal to the plane. static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal); static float Angle(Vector3 from, Vector3 to); static float SignedAngle(Vector3 from, Vector3 to, Vector3 axis); }; void Vec3_Constructor(Vec3* v, float _x, float _y, float _z); #endif