Struct azalea_core::position::Vec3
source · pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
Expand description
Used to represent an exact position in the world where an entity could be.
For blocks, BlockPos
is used instead.
Fields§
§x: f64
§y: f64
§z: f64
Implementations§
source§impl Vec3
impl Vec3
pub fn new(x: f64, y: f64, z: f64) -> Self
sourcepub fn length_sqr(&self) -> f64
pub fn length_sqr(&self) -> f64
Get the distance of this vector to the origin by doing x^2 + y^2 + z^2
.
sourcepub fn distance_to_sqr(&self, other: &Self) -> f64
pub fn distance_to_sqr(&self, other: &Self) -> f64
Get the squared distance from this position to another position.
Equivalent to (self - other).length_sqr()
.
pub fn horizontal_distance_sqr(&self) -> f64
pub fn horizontal_distance_to_sqr(&self, other: &Self) -> f64
sourcepub fn down(&self, y: f64) -> Self
pub fn down(&self, y: f64) -> Self
Return a new instance of this position with the y coordinate decreased by the given number.
sourcepub fn up(&self, y: f64) -> Self
pub fn up(&self, y: f64) -> Self
Return a new instance of this position with the y coordinate increased by the given number.
sourcepub fn north(&self, z: f64) -> Self
pub fn north(&self, z: f64) -> Self
Return a new instance of this position with the z coordinate subtracted by the given number.
sourcepub fn east(&self, x: f64) -> Self
pub fn east(&self, x: f64) -> Self
Return a new instance of this position with the x coordinate increased by the given number.
sourcepub fn south(&self, z: f64) -> Self
pub fn south(&self, z: f64) -> Self
Return a new instance of this position with the z coordinate increased by the given number.
sourcepub fn west(&self, x: f64) -> Self
pub fn west(&self, x: f64) -> Self
Return a new instance of this position with the x coordinate subtracted by the given number.
pub fn dot(&self, other: Self) -> f64
Trait Implementations§
source§impl AddAssign for Vec3
impl AddAssign for Vec3
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read more