12 this->x =
static_cast<float>(
x);
13 this->y =
static_cast<float>(
y);
18 this->x =
static_cast<float>(
x);
19 this->y =
static_cast<float>(
y);
42 return Vec2(
x * scalar,
y * scalar);
46 return Vec2(
x / scalar,
y / scalar);
54 return (
x == other.
x) && (
y == other.
y);
58 return std::sqrt(
x *
x +
y *
y);
62 return std::sqrt((
x - other.
x) * (
x - other.
x) + (
y - other.
y) * (
y - other.
y));
69 operator physx::PxExtendedVec3()
const {
70 return physx::PxExtendedVec3(
x,
y,
z);
72 operator physx::PxVec3()
const {
73 return physx::PxVec3(
x,
y,
z);
75 Vec3(
const physx::PxVec3& other) {
82 Vec3(
float x = 0.0f,
float y = 0.0f,
float z = 0.0f) :
x(
x),
y(
y),
z(
z) {}
98 return (
x == other.
x) && (
y == other.
y) && (
z == other.
z);
110 return (
x < other.
x) && (
y < other.
y) && (
z < other.
z);
115 return x *
x +
y *
y +
z *
z;
135 return Vec3(
x * scalar,
y * scalar,
z * scalar);
139 return std::sqrt(
x *
x +
y *
y +
z *
z);
149 y * other.
z -
z * other.
y,
150 z * other.
x -
x * other.
z,
151 x * other.
y -
y * other.
x);
155 float cosTheta = std::cos(angle);
156 float sinTheta = std::sin(angle);
160 (cosTheta + (1 - cosTheta) * normalizedAxis.
x * normalizedAxis.
x) *
x +
161 ((1 - cosTheta) * normalizedAxis.
x * normalizedAxis.
y - sinTheta * normalizedAxis.
z) *
y +
162 ((1 - cosTheta) * normalizedAxis.
x * normalizedAxis.
z + sinTheta * normalizedAxis.
y) *
z,
164 ((1 - cosTheta) * normalizedAxis.
x * normalizedAxis.
y + sinTheta * normalizedAxis.
z) *
x +
165 (cosTheta + (1 - cosTheta) * normalizedAxis.
y * normalizedAxis.
y) *
y +
166 ((1 - cosTheta) * normalizedAxis.
y * normalizedAxis.
z - sinTheta * normalizedAxis.
x) *
z,
168 ((1 - cosTheta) * normalizedAxis.
x * normalizedAxis.
z - sinTheta * normalizedAxis.
y) *
x +
169 ((1 - cosTheta) * normalizedAxis.
y * normalizedAxis.
z + sinTheta * normalizedAxis.
x) *
y +
170 (cosTheta + (1 - cosTheta) * normalizedAxis.
z * normalizedAxis.
z) *
z);
173 return x * rhs.
x +
y * rhs.
y +
z * rhs.
z;
178 float length = std::sqrt(v.
x * v.
x + v.
y * v.
y + v.
z * v.
z);
179 return Vec3(v.
x / length, v.
y / length, v.
z / length);
185 a.
y * b.
z - a.
z * b.
y,
186 a.
z * b.
x - a.
x * b.
z,
187 a.
x * b.
y - a.
y * b.
x);
192 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
197 Vec4(
float x = 0.0f,
float y = 0.0f,
float z = 0.0f,
float w = 0.0f)
200 :
x(vec.
x),
y(vec.
y),
z(vec.
z),
w(
w) {}
205 return Vec4(
x - rhs.
x,
y - rhs.
y,
z - rhs.
z,
w - rhs.
w);
214 float length = std::sqrt(
x *
x +
y *
y +
z *
z +
w *
w);
216 return Vec4(
x / length,
y / length,
z / length,
w / length);
218 return Vec4(0.0f, 0.0f, 0.0f, 0.0f);
float dot(const Vec3 &a, const Vec3 &b)
Vec3 normalize(const Vec3 &v)
Vec3 cross(const Vec3 &a, const Vec3 &b)
Vec2 operator*(const Vec2 &rhs) const
float distance(const Vec2 &other) const
bool operator==(const Vec2 &other) const
Vec2 operator/(const Vec2 &rhs) const
Vec2(float x=0.0f, float y=0.0f)
Vec2 operator*(float scalar) const
Vec2(uint32_t x, uint32_t y)
Vec2 operator/(float scalar) const
Vec2 & operator+=(const Vec2 &rhs)
Vec2 operator-(const Vec2 &rhs) const
Vec2 operator+(const Vec2 &rhs) const
float dot(const Vec3 &rhs) const
Vec3 operator-(const Vec3 &rhs) const
bool operator<(const Vec3 &other) const
Vec3(float x=0.0f, float y=0.0f, float z=0.0f)
Vec3 cross(const Vec3 &other) const
Vec3 rotate(const Vec3 &axis, float angle) const
bool operator==(const Vec3 &other) const
Vec3 & operator+=(const Vec3 &rhs)
Vec3 operator*(float scalar) const
float lengthSquared() const
Vec3 operator+(const Vec3 &rhs) const
Vec3 & operator-=(const Vec3 &rhs)
Vec4(Vec2 v, float z=0.0f, float w=0.0f)
Vec4(float x=0.0f, float y=0.0f, float z=0.0f, float w=0.0f)
Vec4 operator-(const Vec4 &rhs) const
Vec4(Vec3 vec, float w=0.0f)
Vector4(T x=0, T y=0, T z=0, T w=0)