pub struct Point(pub Vector);
Expand description
Point represents a point on the unit sphere as a normalized 3D vector. Fields should be treated as read-only. Use one of the factory methods for creation.
Tuple Fields§
§0: Vector
Implementations§
source§impl Point
impl Point
sourcepub fn from_coords(x: f64, y: f64, z: f64) -> Self
pub fn from_coords(x: f64, y: f64, z: f64) -> Self
form_coords creates a new normalized point from coordinates.
This always returns a valid point. If the given coordinates can not be normalized the origin point will be returned.
This behavior is different from the C++ construction of a S2Point from coordinates (i.e. S2Point(x, y, z)) in that in C++ they do not Normalize.
sourcepub fn origin() -> Self
pub fn origin() -> Self
origin returns a unique “origin” on the sphere for operations that need a fixed reference point. In particular, this is the “point at infinity” used for point-in-polygon testing (by counting the number of edge crossings).
It should not be a point that is commonly used in edge tests in order to avoid triggering code to handle degenerate cases (this rules out the north and south poles). It should also not be on the boundary of any low-level S2Cell for the same reason.
sourcepub fn cross(&self, other: &Self) -> Self
pub fn cross(&self, other: &Self) -> Self
cross returns a Point that is orthogonal to both p and op. This is similar to p.Cross(op) (the true cross product) except that it does a better job of ensuring orthogonality when the Point is nearly parallel to op, it returns a non-zero result even when p == op or p == -op and the result is a Point.
It satisfies the following properties (f == cross):
(1) f(p, op) != 0 for all p, op
(2) f(op,p) == -f(p,op) unless p == op or p == -op
(3) f(-p,op) == -f(p,op) unless p == op or p == -op
(4) f(p,-op) == -f(p,op) unless p == op or p == -op
sourcepub fn approx_eq(&self, other: &Self) -> bool
pub fn approx_eq(&self, other: &Self) -> bool
approx_eq reports whether the two points are similar enough to be equal.
pub fn normalize(&self) -> Self
pub fn ortho(&self) -> Self
pub fn frame(&self) -> Matrix3<f64>
source§impl Point
impl Point
sourcepub fn chordangle(&self, other: &Point) -> ChordAngle
pub fn chordangle(&self, other: &Point) -> ChordAngle
chordangle constructs a ChordAngle corresponding to the distance between the two given points. The points must be unit length.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Point
impl<'de> Deserialize<'de> for Point
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<'a> From<&'a CellID> for Point
impl<'a> From<&'a CellID> for Point
source§fn from(id: &'a CellID) -> Self
fn from(id: &'a CellID) -> Self
cellIDFromPoint returns a leaf cell containing point p. Usually there is exactly one such cell, but for points along the edge of a cell, any adjacent cell may be (deterministically) chosen. This is because s2.CellIDs are considered to be closed sets. The returned cell will always contain the given point, i.e.
Cell::from(&p).contains_point(&p)
is always true.
source§impl PartialEq<Point> for Point
impl PartialEq<Point> for Point
source§impl Region for Point
impl Region for Point
source§fn rect_bound(&self) -> Rect
fn rect_bound(&self) -> Rect
rect_bound returns a bounding latitude-longitude rectangle from this point.
source§fn contains_cell(&self, _: &Cell) -> bool
fn contains_cell(&self, _: &Cell) -> bool
contains_cell returns false as Points do not contain any other S2 types.
source§fn intersects_cell(&self, c: &Cell) -> bool
fn intersects_cell(&self, c: &Cell) -> bool
intersects_cell reports whether this Point intersects the given cell.