#[repr(C)]pub struct S2Point {
pub x: f64,
pub y: f64,
pub z: f64,
}Expand description
An S2Point represents a point on the unit sphere as a 3D vector. Usually points are normalized to be unit length, but some methods do not require this. See util/math/vector.h for the methods available. Among other things, there are overloaded operators that make it convenient to write arithmetic expressions (e.g. p1 + p2).
NOTE: asumes only f64 or greater is used.
Implements the GetXY and GetZ traits
§Usage
Methods that are available:
S2Point::new: Create a new S2PointS2Point::is_empty: Check if the S2Point is emptyS2Point::face: Returns the S2 face assocated with this pointS2Point::angle: Returns the angle between this point and anotherS2Point::cross: Get the cross product of two XYZ PointsS2Point::to_face_st: Convert an S2Point to an S2Point in normalized vector coordinatesS2Point::get_face: Returns the S2 face assocated with this pointS2Point::dot: Get the dot product of two XYZ PointsS2Point::abs: Returns the absolute value of the pointS2Point::invert: Inverts the pointS2Point::len: Returns the length of the pointS2Point::norm: Returns the vector’s squared norm.S2Point::norm2: The dot product of the point with itselfS2Point::normalize: Normalizes the pointS2Point::distance: return the distance from this point to the other pointS2Point::largest_abs_component: Returns the largest absolute component of the pointS2Point::intermediate: Returns the intermediate point between this and the other pointS2Point::from_face_uv: Convert an Face-U-V coordinate to an S2PointS2Point::from_face_st: Convert an Face-S-T coordinate to an S2Point
Fields§
§x: f64The x component.
y: f64The y component.
z: f64The z component.
Implementations§
Source§impl S2Point
impl S2Point
Sourcepub fn angle(&self, b: &Self) -> f64
pub fn angle(&self, b: &Self) -> f64
Returns the angle between “this” and v in radians, in the range [0, pi]. If either vector is zero-length, or nearly zero-length, the result will be zero, regardless of the other value.
Sourcepub fn to_face_st(&self) -> (u8, f64, f64)
pub fn to_face_st(&self) -> (u8, f64, f64)
Returns a Face-ST representation of this point
Sourcepub fn distance(&self, b: &Self) -> f64
pub fn distance(&self, b: &Self) -> f64
return the distance from this point to the other point in radians
Sourcepub fn largest_abs_component(&self) -> u8
pub fn largest_abs_component(&self) -> u8
Returns the largest absolute component of the point.
Sourcepub fn intermediate(&self, b: &Self, t: f64) -> Self
pub fn intermediate(&self, b: &Self, t: f64) -> Self
Returns the intermediate point between this and the other point.
Sourcepub fn from_face_uv(face: u8, u: f64, v: f64) -> Self
pub fn from_face_uv(face: u8, u: f64, v: f64) -> Self
Convert a u-v coordinate to an XYZ Point.
Sourcepub fn from_face_st(face: u8, s: f64, t: f64) -> Self
pub fn from_face_st(face: u8, s: f64, t: f64) -> Self
Convert an s-t coordinate to an XYZ Point.
Trait Implementations§
Source§impl AddAssign<f64> for S2Point
impl AddAssign<f64> for S2Point
Source§fn add_assign(&mut self, other: f64)
fn add_assign(&mut self, other: f64)
+= operation. Read moreSource§impl AddAssign for S2Point
impl AddAssign for S2Point
Source§fn add_assign(&mut self, other: S2Point)
fn add_assign(&mut self, other: S2Point)
+= operation. Read moreSource§impl BoxIndexAccessor for S2Point
impl BoxIndexAccessor for S2Point
Source§impl<'de> Deserialize<'de> for S2Point
impl<'de> Deserialize<'de> for S2Point
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl DivAssign<f64> for S2Point
impl DivAssign<f64> for S2Point
Source§fn div_assign(&mut self, other: f64)
fn div_assign(&mut self, other: f64)
/= operation. Read moreSource§impl DivAssign for S2Point
impl DivAssign for S2Point
Source§fn div_assign(&mut self, other: S2Point)
fn div_assign(&mut self, other: S2Point)
/= operation. Read moreSource§impl<M: Clone + Default> From<&VectorPoint<M>> for S2Point
impl<M: Clone + Default> From<&VectorPoint<M>> for S2Point
Source§fn from(v: &VectorPoint<M>) -> Self
fn from(v: &VectorPoint<M>) -> Self
Source§impl<M: Clone + Default> From<&mut VectorPoint<M>> for S2Point
impl<M: Clone + Default> From<&mut VectorPoint<M>> for S2Point
Source§fn from(v: &mut VectorPoint<M>) -> Self
fn from(v: &mut VectorPoint<M>) -> Self
Source§impl MulAssign<f64> for S2Point
impl MulAssign<f64> for S2Point
Source§fn mul_assign(&mut self, other: f64)
fn mul_assign(&mut self, other: f64)
*= operation. Read moreSource§impl MulAssign for S2Point
impl MulAssign for S2Point
Source§fn mul_assign(&mut self, other: S2Point)
fn mul_assign(&mut self, other: S2Point)
*= operation. Read moreSource§impl Ord for S2Point
impl Ord for S2Point
Source§impl PartialOrd for S2Point
impl PartialOrd for S2Point
Source§impl RemAssign<f64> for S2Point
impl RemAssign<f64> for S2Point
Source§fn rem_assign(&mut self, other: f64)
fn rem_assign(&mut self, other: f64)
%= operation. Read moreSource§impl SubAssign<f64> for S2Point
impl SubAssign<f64> for S2Point
Source§fn sub_assign(&mut self, other: f64)
fn sub_assign(&mut self, other: f64)
-= operation. Read moreSource§impl SubAssign for S2Point
impl SubAssign for S2Point
Source§fn sub_assign(&mut self, other: S2Point)
fn sub_assign(&mut self, other: S2Point)
-= operation. Read moreimpl Copy for S2Point
impl Eq for S2Point
impl StructuralPartialEq for S2Point
Auto Trait Implementations§
impl Freeze for S2Point
impl RefUnwindSafe for S2Point
impl Send for S2Point
impl Sync for S2Point
impl Unpin for S2Point
impl UnwindSafe for S2Point
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClampWGS84Point for T
impl<T> ClampWGS84Point for T
Source§fn clamp_wgs84(&mut self)
fn clamp_wgs84(&mut self)
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().