#[repr(C)]pub struct VectorPoint<M = Map<String, ValueType>>where
M: Clone,{
pub x: f64,
pub y: f64,
pub z: Option<f64>,
pub m: Option<M>,
pub t: Option<f64>,
}Expand description
§Vector Points
§Description
A Vector Point uses a structure for 2D or 3D points. Useful for geometry that also has m-values
Implements the ops Add, AddAssign, Sub, SubAssign, Mul, MulAssign, Div, DivAssign, Rem, RemAssign, Neg, PartialEq, and Eq.
Also implements local traits GetXY, GetZ, GetM, SetXY, SetZ, SetM, NewXY, NewXYM, NewXYZ, NewXYZM, MValueCompatible, MValue, and Interpolate.
§Fields
x: X coordinatey: Y coordinatez: Z coordinate or “altitude”. May be Nonem: M-Valuet: T for tolerance. A tmp value often used for simplification if needed.
§Usage
VectorPoint::new: Creates a new VectorPointVectorPoint::to_m_value: Convert to an MValue VectorPoint using to_m_valueVectorPoint::project: Project the point into the 0->1 coordinate systemVectorPoint::unproject: Unproject the point from the 0->1 coordinate systemVectorPoint::is_empty: Returns true if the point is the zero vectorVectorPoint::face: Returns the S2 face assocated with this point- `VectorPoint::modulo: Apply modular arithmetic
VectorPoint::angle: 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 valueVectorPoint::cross: Get the cross product of two Vector PointsVectorPoint::dot: dot returns the standard dot product of v and ov.VectorPoint::abs: Returns the absolute value of the point.VectorPoint::invert: Returns the inverse of the pointVectorPoint::len: Returns the length of the pointVectorPoint::norm: norm returns the vector’s norm. (sqrt of norm2)VectorPoint::norm2: norm2 returns the vector’s squared norm (self.dot(self))VectorPoint::normalize: Normalize this point to unit lengthVectorPoint::distance: return the distance from this point to the other pointVectorPoint::largest_abs_component: Returns the largest absolute component of the pointVectorPoint::interpolate: Interpolate between two points with a given t value
Fields§
§x: f64X coordinate
y: f64Y coordinate
z: Option<f64>Z coordinate or “altitude”. May be None
m: Option<M>M-Value
t: Option<f64>T for tolerance. A tmp value used for simplification
Implementations§
Source§impl VectorPoint
impl VectorPoint
Source§impl<M> VectorPoint<M>where
M: Clone,
impl<M> VectorPoint<M>where
M: Clone,
Sourcepub fn new_xyz(x: f64, y: f64, z: f64, m: Option<M>) -> VectorPoint<M>
pub fn new_xyz(x: f64, y: f64, z: f64, m: Option<M>) -> VectorPoint<M>
Create a new point with xyz
Sourcepub fn to_m_value(&self) -> VectorPoint
pub fn to_m_value(&self) -> VectorPoint
Convert to an MValue VectorPoint
Sourcepub fn project(&mut self, bbox: Option<&mut BBox3D>)
pub fn project(&mut self, bbox: Option<&mut BBox3D>)
Project the point into the 0->1 coordinate system
Sourcepub fn unproject(&mut self)
pub fn unproject(&mut self)
Unproject the point from the 0->1 coordinate system back to a lon-lat coordinate
Sourcepub fn modulo(self, modulus: f64) -> VectorPoint<M>
pub fn modulo(self, modulus: f64) -> VectorPoint<M>
Apply modular arithmetic to x, y, and z using modulus
Sourcepub fn angle<M2>(&self, b: &VectorPoint<M2>) -> f64where
M2: Clone,
pub fn angle<M2>(&self, b: &VectorPoint<M2>) -> f64where
M2: Clone,
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 cross<M2>(&self, b: &VectorPoint<M2>) -> VectorPoint<M>where
M2: Clone,
pub fn cross<M2>(&self, b: &VectorPoint<M2>) -> VectorPoint<M>where
M2: Clone,
Get the cross product of two Vector Points
Sourcepub fn dot<M2>(&self, b: &VectorPoint<M2>) -> f64where
M2: Clone,
pub fn dot<M2>(&self, b: &VectorPoint<M2>) -> f64where
M2: Clone,
dot returns the standard dot product of v and ov.
Sourcepub fn abs(&self) -> VectorPoint<M>
pub fn abs(&self) -> VectorPoint<M>
Returns the absolute value of the point.
Sourcepub fn invert(&self) -> VectorPoint<M>
pub fn invert(&self) -> VectorPoint<M>
Returns the inverse of the point
Sourcepub fn distance<M2>(&self, b: &VectorPoint<M2>) -> f64where
M2: Clone,
pub fn distance<M2>(&self, b: &VectorPoint<M2>) -> f64where
M2: Clone,
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<M2>(&self, b: &VectorPoint<M2>, t: f64) -> VectorPoint<M>where
M2: Clone,
pub fn intermediate<M2>(&self, b: &VectorPoint<M2>, t: f64) -> VectorPoint<M>where
M2: Clone,
Returns the intermediate point between this and the other point.
Sourcepub fn perpendicular(&self) -> VectorPoint<M>
pub fn perpendicular(&self) -> VectorPoint<M>
Returns the perpendicular vector
Trait Implementations§
Source§impl<M1, M2> Add<&VectorPoint<M2>> for &VectorPoint<M1>
impl<M1, M2> Add<&VectorPoint<M2>> for &VectorPoint<M1>
Source§type Output = VectorPoint<M1>
type Output = VectorPoint<M1>
+ operator.Source§fn add(
self,
other: &VectorPoint<M2>,
) -> <&VectorPoint<M1> as Add<&VectorPoint<M2>>>::Output
fn add( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Add<&VectorPoint<M2>>>::Output
+ operation. Read moreSource§impl<M1, M2> AddAssign<&VectorPoint<M2>> for VectorPoint<M1>
impl<M1, M2> AddAssign<&VectorPoint<M2>> for VectorPoint<M1>
Source§fn add_assign(&mut self, other: &VectorPoint<M2>)
fn add_assign(&mut self, other: &VectorPoint<M2>)
+= operation. Read moreSource§impl<M> AddAssign<f64> for VectorPoint<M>where
M: Clone,
impl<M> AddAssign<f64> for VectorPoint<M>where
M: Clone,
Source§fn add_assign(&mut self, other: f64)
fn add_assign(&mut self, other: f64)
+= operation. Read moreSource§impl<M> Clone for VectorPoint<M>where
M: Clone,
impl<M> Clone for VectorPoint<M>where
M: Clone,
Source§fn clone(&self) -> VectorPoint<M>
fn clone(&self) -> VectorPoint<M>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<M> Debug for VectorPoint<M>
impl<M> Debug for VectorPoint<M>
Source§impl<M> Default for VectorPoint<M>
impl<M> Default for VectorPoint<M>
Source§fn default() -> VectorPoint<M>
fn default() -> VectorPoint<M>
Source§impl<'de, M> Deserialize<'de> for VectorPoint<M>where
M: Clone + Deserialize<'de>,
impl<'de, M> Deserialize<'de> for VectorPoint<M>where
M: Clone + Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<VectorPoint<M>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<VectorPoint<M>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<M1, M2> Div<&VectorPoint<M2>> for &VectorPoint<M1>
impl<M1, M2> Div<&VectorPoint<M2>> for &VectorPoint<M1>
Source§type Output = VectorPoint<M1>
type Output = VectorPoint<M1>
/ operator.Source§fn div(
self,
other: &VectorPoint<M2>,
) -> <&VectorPoint<M1> as Div<&VectorPoint<M2>>>::Output
fn div( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Div<&VectorPoint<M2>>>::Output
/ operation. Read moreSource§impl<M1, M2> DivAssign<&VectorPoint<M2>> for VectorPoint<M1>
impl<M1, M2> DivAssign<&VectorPoint<M2>> for VectorPoint<M1>
Source§fn div_assign(&mut self, other: &VectorPoint<M2>)
fn div_assign(&mut self, other: &VectorPoint<M2>)
/= operation. Read moreSource§impl<M> DivAssign<f64> for VectorPoint<M>where
M: Clone,
impl<M> DivAssign<f64> for VectorPoint<M>where
M: Clone,
Source§fn div_assign(&mut self, other: f64)
fn div_assign(&mut self, other: f64)
/= operation. Read moreSource§impl<M, P> From<&P> for VectorPoint<M>
impl<M, P> From<&P> for VectorPoint<M>
Source§fn from(p: &P) -> VectorPoint<M>
fn from(p: &P) -> VectorPoint<M>
Source§impl<M> From<Point> for VectorPoint<M>where
M: Clone,
impl<M> From<Point> for VectorPoint<M>where
M: Clone,
Source§fn from(p: Point) -> VectorPoint<M>
fn from(p: Point) -> VectorPoint<M>
Source§impl<M> From<Point3D> for VectorPoint<M>where
M: Clone,
impl<M> From<Point3D> for VectorPoint<M>where
M: Clone,
Source§fn from(p: Point3D) -> VectorPoint<M>
fn from(p: Point3D) -> VectorPoint<M>
Source§impl<M> GetM<M> for VectorPoint<M>where
M: Clone,
impl<M> GetM<M> for VectorPoint<M>where
M: Clone,
Source§impl<M> GetXY for VectorPoint<M>where
M: Clone,
impl<M> GetXY for VectorPoint<M>where
M: Clone,
Source§impl<M> GetZ for VectorPoint<M>where
M: Clone,
impl<M> GetZ for VectorPoint<M>where
M: Clone,
Source§impl<M> Interpolate for VectorPoint<M>where
M: Interpolate + Clone,
impl<M> Interpolate for VectorPoint<M>where
M: Interpolate + Clone,
Source§fn interpolate(&self, other: &VectorPoint<M>, t: f64) -> VectorPoint<M>
fn interpolate(&self, other: &VectorPoint<M>, t: f64) -> VectorPoint<M>
Source§impl<M1, M2> Mul<&VectorPoint<M2>> for &VectorPoint<M1>
impl<M1, M2> Mul<&VectorPoint<M2>> for &VectorPoint<M1>
Source§type Output = VectorPoint<M1>
type Output = VectorPoint<M1>
* operator.Source§fn mul(
self,
other: &VectorPoint<M2>,
) -> <&VectorPoint<M1> as Mul<&VectorPoint<M2>>>::Output
fn mul( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Mul<&VectorPoint<M2>>>::Output
* operation. Read moreSource§impl<M1, M2> MulAssign<&VectorPoint<M2>> for VectorPoint<M1>
impl<M1, M2> MulAssign<&VectorPoint<M2>> for VectorPoint<M1>
Source§fn mul_assign(&mut self, other: &VectorPoint<M2>)
fn mul_assign(&mut self, other: &VectorPoint<M2>)
*= operation. Read moreSource§impl<M> MulAssign<f64> for VectorPoint<M>where
M: Clone,
impl<M> MulAssign<f64> for VectorPoint<M>where
M: Clone,
Source§fn mul_assign(&mut self, other: f64)
fn mul_assign(&mut self, other: f64)
*= operation. Read moreSource§impl<M> Neg for &VectorPoint<M>where
M: Clone,
impl<M> Neg for &VectorPoint<M>where
M: Clone,
Source§impl<M> NewXY for VectorPoint<M>where
M: Clone,
impl<M> NewXY for VectorPoint<M>where
M: Clone,
Source§impl<M> NewXYM<M> for VectorPoint<M>where
M: Clone,
impl<M> NewXYM<M> for VectorPoint<M>where
M: Clone,
Source§impl<M> NewXYZ for VectorPoint<M>where
M: Clone,
impl<M> NewXYZ for VectorPoint<M>where
M: Clone,
Source§impl<M> NewXYZM<M> for VectorPoint<M>where
M: Clone,
impl<M> NewXYZM<M> for VectorPoint<M>where
M: Clone,
Source§impl<M> Ord for VectorPoint<M>where
M: Clone,
impl<M> Ord for VectorPoint<M>where
M: Clone,
Source§fn cmp(&self, other: &VectorPoint<M>) -> Ordering
fn cmp(&self, other: &VectorPoint<M>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<M> PartialEq for VectorPoint<M>where
M: Clone,
impl<M> PartialEq for VectorPoint<M>where
M: Clone,
Source§impl<M> PartialOrd for VectorPoint<M>where
M: Clone,
impl<M> PartialOrd for VectorPoint<M>where
M: Clone,
Source§impl<M> RemAssign<f64> for VectorPoint<M>where
M: Clone,
impl<M> RemAssign<f64> for VectorPoint<M>where
M: Clone,
Source§fn rem_assign(&mut self, modulus: f64)
fn rem_assign(&mut self, modulus: f64)
%= operation. Read moreSource§impl<M> Serialize for VectorPoint<M>
impl<M> Serialize for VectorPoint<M>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl<M> SetM<M> for VectorPoint<M>where
M: Clone,
impl<M> SetM<M> for VectorPoint<M>where
M: Clone,
Source§impl<M> SetXY for VectorPoint<M>where
M: Clone,
impl<M> SetXY for VectorPoint<M>where
M: Clone,
Source§impl<M> SetZ for VectorPoint<M>where
M: Clone,
impl<M> SetZ for VectorPoint<M>where
M: Clone,
Source§impl<M1, M2> Sub<&VectorPoint<M2>> for &VectorPoint<M1>
impl<M1, M2> Sub<&VectorPoint<M2>> for &VectorPoint<M1>
Source§type Output = VectorPoint<M1>
type Output = VectorPoint<M1>
- operator.Source§fn sub(
self,
other: &VectorPoint<M2>,
) -> <&VectorPoint<M1> as Sub<&VectorPoint<M2>>>::Output
fn sub( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Sub<&VectorPoint<M2>>>::Output
- operation. Read moreSource§impl<M1, M2> SubAssign<&VectorPoint<M2>> for VectorPoint<M1>
impl<M1, M2> SubAssign<&VectorPoint<M2>> for VectorPoint<M1>
Source§fn sub_assign(&mut self, other: &VectorPoint<M2>)
fn sub_assign(&mut self, other: &VectorPoint<M2>)
-= operation. Read moreSource§impl<M> SubAssign<f64> for VectorPoint<M>where
M: Clone,
impl<M> SubAssign<f64> for VectorPoint<M>where
M: Clone,
Source§fn sub_assign(&mut self, other: f64)
fn sub_assign(&mut self, other: f64)
-= operation. Read more