19 auto *
v =
new Vec3(x_, y_, z_);
26 return x_ * other->x_ + y_ * other->y_ + z_ * other->z_;
31 return new Vec3(y_ * other->z_ - z_ * other->y_, z_ * other->x_ - x_ * other->z_,
32 x_ * other->y_ - y_ * other->x_);
36 if (!other)
throw eve::Exception(
"Vec3.distanceTo: other is null");
37 float dx = x_ - other->x_;
38 float dy = y_ - other->y_;
39 float dz = z_ - other->z_;
40 return std::sqrt(dx * dx + dy * dy + dz * dz);
45 return new Vec3(x_ + other->x_, y_ + other->y_, z_ + other->z_);
50 return new Vec3(x_ - other->x_, y_ - other->y_, z_ - other->z_);
57 return new Vec3(x_ + (other->x_ - x_) * t, y_ + (other->y_ - y_) * t,
58 z_ + (other->z_ - z_) * t);
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
void normalize()
Normalizes in place / returns a normalized copy.