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);
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].