18 auto *
v =
new Vec2(x_, y_);
25 return x_ * other->x_ + y_ * other->y_;
30 return x_ * other->y_ - y_ * other->x_;
34 if (!other)
throw eve::Exception(
"Vec2.distanceTo: other is null");
35 float dx = x_ - other->x_;
36 float dy = y_ - other->y_;
44 return new Vec2(x_ + other->x_, y_ + other->y_);
49 return new Vec2(x_ - other->x_, y_ - other->y_);
56 return new Vec2(x_ + (other->x_ - x_) *
t, y_ + (other->y_ - y_) *
t);
76 auto *
v =
new Vec3(x_, y_, z_);
83 return x_ * other->x_ + y_ * other->y_ + z_ * other->z_;
88 return new Vec3(y_ * other->z_ - z_ * other->y_, z_ * other->x_ - x_ * other->z_, x_ * other->y_ - y_ * other->x_);
92 if (!other)
throw eve::Exception(
"Vec3.distanceTo: other is null");
93 float dx = x_ - other->x_;
94 float dy = y_ - other->y_;
95 float dz = z_ - other->z_;
101 return new Vec3(x_ + other->x_, y_ + other->y_, z_ + other->z_);
106 return new Vec3(x_ - other->x_, y_ - other->y_, z_ - other->z_);
113 return new Vec3(x_ + (other->x_ - x_) *
t, y_ + (other->y_ - y_) *
t, z_ + (other->z_ - z_) *
t);
EVENGINE_API_FOUNDATION public API.
2D float vector (script-facing math module value).
Vec2 * sub(const Vec2 *other) const
Vec2 * normalized() const
float cross(const Vec2 *other) const
Cross product with other.
float dot(const Vec2 *other) const
Atan2 angle in radians.
Vec2 * scale(float s) const
float angle() const
Atan2 angle in radians.
float distanceTo(const Vec2 *other) const
Euclidean distance to other.
float length() const
Magnitude (and squared magnitude).
Vec2 * clone() const
Copies this vector.
Vec2 * add(const Vec2 *other) const
Arithmetic helpers returning new (caller-owned) vectors.
void normalize()
Normalizes in place / returns a normalized copy.
Vec2 * lerpTo(const Vec2 *other, float t) const
Linear interpolation to other at t in [0,1].
3D float vector (script-facing math module value).
Vec3 * normalized() const
Vec3 * cross(const Vec3 *other) const
Vec3 * clone() const
Copies this vector.
Vec3 * sub(const Vec3 *other) const
Vec3 * lerpTo(const Vec3 *other, float t) const
Linear interpolation to other at t in [0,1].
float length() const
Magnitude (and squared magnitude).
Vec3 * scale(float s) const
Vec3 * add(const Vec3 *other) const
Arithmetic helpers returning new (caller-owned) vectors.
float dot(const Vec3 *other) const
Dot/cross product and distance.
float distanceTo(const Vec3 *other) const
Euclidean distance to other.
void normalize()
Normalizes in place / returns a normalized copy.