diff options
| author | mat <git@matdoes.dev> | 2026-01-18 09:50:45 -1245 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-19 05:35:49 +0700 |
| commit | 268c62587e090c72b67a29e1cc42cda6c9d7340b (patch) | |
| tree | 961d0b4d0bd22d17f4ad6c8b77f02f02566b838e /azalea-core/src | |
| parent | fb92f65b3da49b6487bf6fa05010b12a3ab5d4ed (diff) | |
| download | azalea-drasl-268c62587e090c72b67a29e1cc42cda6c9d7340b.tar.xz | |
add simulation-based pathfinder execution engine
Diffstat (limited to 'azalea-core/src')
| -rw-r--r-- | azalea-core/src/position.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index f664957f..09246423 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -126,6 +126,15 @@ macro_rules! vec3_impl { self.x * other.x + self.y * other.y + self.z * other.z } + #[inline] + pub fn cross(&self, other: Self) -> Self { + Self::new( + self.y * other.z - self.z * other.y, + self.z * other.x - self.x * other.z, + self.x * other.y - self.y * other.x, + ) + } + /// Make a new position with the lower coordinates for each axis. pub fn min(&self, other: Self) -> Self { Self { @@ -333,6 +342,7 @@ impl simdnbt::FromNbtTag for Vec3 { impl Vec3 { /// Get the distance of this vector to the origin by doing /// `sqrt(x^2 + y^2 + z^2)`. + #[doc(alias = "modulus")] pub fn length(&self) -> f64 { f64::sqrt(self.x * self.x + self.y * self.y + self.z * self.z) } @@ -343,6 +353,13 @@ impl Vec3 { (self - other).length() } + pub fn horizontal_distance_to(self, other: Self) -> f64 { + self.horizontal_distance_squared_to(other).sqrt() + } + pub fn horizontal_distance(self) -> f64 { + self.horizontal_distance_squared().sqrt() + } + pub fn x_rot(self, radians: f32) -> Vec3 { let x_delta = math::cos(radians); let y_delta = math::sin(radians); |
