S2Point

Struct S2Point 

Source
#[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:

Fields§

§x: f64

The x component.

§y: f64

The y component.

§z: f64

The z component.

Implementations§

Source§

impl S2Point

Source

pub fn new(x: f64, y: f64, z: f64) -> Self

Creates a new S2Point.

Source

pub fn is_empty(&self) -> bool

Returns true if the point is the zero vector.

Source

pub fn face(&self, f: u8) -> f64

Returns the S2 face assocated with this point

Source

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.

Source

pub fn cross(&self, b: &Self) -> Self

Get the cross product of two XYZ Points

Source

pub fn to_face_st(&self) -> (u8, f64, f64)

Returns a Face-ST representation of this point

Source

pub fn get_face(&self) -> u8

Returns the S2 face assocated with this point

Source

pub fn dot(&self, b: &Self) -> f64

dot returns the standard dot product of v and ov.

Source

pub fn abs(&self) -> Self

Returns the absolute value of the point.

Source

pub fn invert(&self) -> Self

Returns the inverse of the point

Source

pub fn len(&self) -> f64

Returns the length of the point.

Source

pub fn norm(&self) -> f64

Returns the vector’s squared norm.

Source

pub fn norm2(&self) -> f64

The dot product of the point with itself

Source

pub fn normalize(&mut self)

Normalize this point to unit length.

Source

pub fn distance(&self, b: &Self) -> f64

return the distance from this point to the other point in radians

Source

pub fn largest_abs_component(&self) -> u8

Returns the largest absolute component of the point.

Source

pub fn intermediate(&self, b: &Self, t: f64) -> Self

Returns the intermediate point between this and the other point.

Source

pub fn from_face_uv(face: u8, u: f64, v: f64) -> Self

Convert a u-v coordinate to an XYZ Point.

Source

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 Add<f64> for S2Point

Source§

type Output = S2Point

The resulting type after applying the + operator.
Source§

fn add(self, other: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for S2Point

Source§

type Output = S2Point

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<f64> for S2Point

Source§

fn add_assign(&mut self, other: f64)

Performs the += operation. Read more
Source§

impl AddAssign for S2Point

Source§

fn add_assign(&mut self, other: S2Point)

Performs the += operation. Read more
Source§

impl BoxIndexAccessor for S2Point

Source§

fn bbox(&self) -> BBox

Get the bounding box of the item
Source§

fn hilbert(&self, _index_bbox: &BBox) -> u64

Get the hilbert value of the item
Source§

impl Clone for S2Point

Source§

fn clone(&self) -> S2Point

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for S2Point

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for S2Point

Source§

fn default() -> S2Point

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for S2Point

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Div<f64> for S2Point

Source§

type Output = S2Point

The resulting type after applying the / operator.
Source§

fn div(self, other: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for S2Point

Source§

type Output = S2Point

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<f64> for S2Point

Source§

fn div_assign(&mut self, other: f64)

Performs the /= operation. Read more
Source§

impl DivAssign for S2Point

Source§

fn div_assign(&mut self, other: S2Point)

Performs the /= operation. Read more
Source§

impl<M: Clone + Default> From<&LonLat<M>> for S2Point

Source§

fn from(lonlat: &LonLat<M>) -> Self

Converts to this type from the input type.
Source§

impl<M: Clone + Default> From<&S2Point> for LonLat<M>

Source§

fn from(p: &S2Point) -> Self

Converts to this type from the input type.
Source§

impl From<&S2Point> for S2CellId

Source§

fn from(value: &S2Point) -> Self

Converts to this type from the input type.
Source§

impl<M: Clone + Default> From<&VectorPoint<M>> for S2Point

Source§

fn from(v: &VectorPoint<M>) -> Self

Converts to this type from the input type.
Source§

impl<M: Clone + Default> From<&mut VectorPoint<M>> for S2Point

Source§

fn from(v: &mut VectorPoint<M>) -> Self

Converts to this type from the input type.
Source§

impl From<S2CellId> for S2Point

Source§

fn from(cellid: S2CellId) -> Self

Converts to this type from the input type.
Source§

impl GetXY for S2Point

Source§

fn x(&self) -> f64

Returns the x value
Source§

fn y(&self) -> f64

Returns the y value
Source§

fn xy(&self) -> (f64, f64)

Returns the x and y values
Source§

impl GetZ for S2Point

Source§

fn z(&self) -> Option<f64>

Returns the z value
Source§

impl Mul<f64> for S2Point

Source§

type Output = S2Point

The resulting type after applying the * operator.
Source§

fn mul(self, other: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for S2Point

Source§

type Output = S2Point

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<f64> for S2Point

Source§

fn mul_assign(&mut self, other: f64)

Performs the *= operation. Read more
Source§

impl MulAssign for S2Point

Source§

fn mul_assign(&mut self, other: S2Point)

Performs the *= operation. Read more
Source§

impl Neg for S2Point

Source§

type Output = S2Point

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl NewXY for S2Point

Source§

fn new_xy(x: f64, y: f64) -> Self

Create a new point with xy
Source§

impl NewXYZ for S2Point

Source§

fn new_xyz(x: f64, y: f64, z: f64) -> Self

Create a new point with xyz
Source§

impl Ord for S2Point

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for S2Point

Source§

fn eq(&self, other: &S2Point) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for S2Point

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Rem<f64> for S2Point

Source§

type Output = S2Point

The resulting type after applying the % operator.
Source§

fn rem(self, other: f64) -> Self::Output

Performs the % operation. Read more
Source§

impl RemAssign<f64> for S2Point

Source§

fn rem_assign(&mut self, other: f64)

Performs the %= operation. Read more
Source§

impl Serialize for S2Point

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SetXY for S2Point

Source§

fn set_x(&mut self, x: f64)

Set the x value
Source§

fn set_y(&mut self, y: f64)

Set the y value
Source§

fn set_xy(&mut self, x: f64, y: f64)

Set both x and y
Source§

impl SetZ for S2Point

Source§

fn set_z(&mut self, z: f64)

Set the z value
Source§

impl Sub<f64> for S2Point

Source§

type Output = S2Point

The resulting type after applying the - operator.
Source§

fn sub(self, other: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for S2Point

Source§

type Output = S2Point

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<f64> for S2Point

Source§

fn sub_assign(&mut self, other: f64)

Performs the -= operation. Read more
Source§

impl SubAssign for S2Point

Source§

fn sub_assign(&mut self, other: S2Point)

Performs the -= operation. Read more
Source§

impl Copy for S2Point

Source§

impl Eq for S2Point

Source§

impl StructuralPartialEq for S2Point

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClampWGS84Point for T
where T: GetXY + SetXY,

Source§

fn clamp_wgs84(&mut self)

Updates the WGS84 point’s x and y values as needed to be valid WGS84
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SetXYZ for T
where T: SetXY + SetZ,

Source§

fn set_xyz(&mut self, x: f64, y: f64, z: f64)

Set x, y and z
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> FullXY for T
where T: GetXYZ + SetXY + NewXY + Clone + PartialEq + Ord,

Source§

impl<T> FullXYZ for T
where T: GetXYZ + SetXYZ + NewXYZ + Clone + PartialEq + Ord,

Source§

impl<T> GetXYZ for T
where T: GetXY + GetZ,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,