Struct VectorPoint

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

A Vector Point uses a structure for 2D or 3D points

Fields§

§x: f64

X coordinate

§y: f64

Y 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

Source

pub fn from_xy(x: f64, y: f64) -> VectorPoint

Helper function for tests. Create a new point quickly from an xy coordinate

Source

pub fn from_xyz(x: f64, y: f64, z: f64) -> VectorPoint

Helper function for tests. Create a new point quickly from an xyz coordinate

Source§

impl<M> VectorPoint<M>
where M: Clone,

Source

pub fn new(x: f64, y: f64, z: Option<f64>, m: Option<M>) -> VectorPoint<M>

Create a new point

Source

pub fn new_xy(x: f64, y: f64, m: Option<M>) -> VectorPoint<M>

Create a new point with xy

Source

pub fn new_xyz(x: f64, y: f64, z: f64, m: Option<M>) -> VectorPoint<M>

Create a new point with xyz

Source

pub fn project(&mut self, bbox: Option<&mut BBox3D>)

Project the point into the 0->1 coordinate system

Source

pub fn unproject(&mut self)

Unproject the point from the 0->1 coordinate system back to a lon-lat coordinate

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 modulo(self, modulus: f64) -> VectorPoint<M>

Apply modular arithmetic to x, y, and z using modulus

Source

pub fn angle<M2>(&self, b: &VectorPoint<M2>) -> f64
where 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.

Source

pub fn cross<M2>(&self, b: &VectorPoint<M2>) -> VectorPoint<M>
where M2: Clone,

Get the cross product of two Vector Points

Source

pub fn dot<M2>(&self, b: &VectorPoint<M2>) -> f64
where M2: Clone,

dot returns the standard dot product of v and ov.

Source

pub fn abs(&self) -> VectorPoint<M>

Returns the absolute value of the point.

Source

pub fn invert(&self) -> VectorPoint<M>

Returns the inverse of the point

Source

pub fn len(&self) -> f64

Returns the length of the point.

Source

pub fn norm(&self) -> f64

norm returns the vector’s norm.

Source

pub fn norm2(&self) -> f64

norm2 returns the vector’s squared norm.

Source

pub fn normalize(&mut self)

Normalize this point to unit length.

Source

pub fn distance<M2>(&self, b: &VectorPoint<M2>) -> f64
where M2: Clone,

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<M2>(&self, b: &VectorPoint<M2>, t: f64) -> VectorPoint<M>
where M2: Clone,

Returns the intermediate point between this and the other point.

Source

pub fn perpendicular(&self) -> VectorPoint<M>

Returns the perpendicular vector

Trait Implementations§

Source§

impl<M1, M2> Add<&VectorPoint<M2>> for &VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

type Output = VectorPoint<M1>

The resulting type after applying the + operator.
Source§

fn add( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Add<&VectorPoint<M2>>>::Output

Performs the + operation. Read more
Source§

impl<M> Add<f64> for &VectorPoint<M>
where M: Clone,

Source§

type Output = VectorPoint<M>

The resulting type after applying the + operator.
Source§

fn add(self, other: f64) -> <&VectorPoint<M> as Add<f64>>::Output

Performs the + operation. Read more
Source§

impl<M1, M2> AddAssign<&VectorPoint<M2>> for VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

fn add_assign(&mut self, other: &VectorPoint<M2>)

Performs the += operation. Read more
Source§

impl<M> AddAssign<f64> for VectorPoint<M>
where M: Clone,

Source§

fn add_assign(&mut self, other: f64)

Performs the += operation. Read more
Source§

impl<M> Clone for VectorPoint<M>
where M: Clone,

Source§

fn clone(&self) -> VectorPoint<M>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<M> Debug for VectorPoint<M>
where M: Debug + Clone,

Source§

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

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

impl<M> Default for VectorPoint<M>
where M: Default + Clone,

Source§

fn default() -> VectorPoint<M>

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

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>,

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

impl<M1, M2> Div<&VectorPoint<M2>> for &VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

type Output = VectorPoint<M1>

The resulting type after applying the / operator.
Source§

fn div( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Div<&VectorPoint<M2>>>::Output

Performs the / operation. Read more
Source§

impl<M> Div<f64> for &VectorPoint<M>
where M: Clone,

Source§

type Output = VectorPoint<M>

The resulting type after applying the / operator.
Source§

fn div(self, other: f64) -> <&VectorPoint<M> as Div<f64>>::Output

Performs the / operation. Read more
Source§

impl<M1, M2> DivAssign<&VectorPoint<M2>> for VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

fn div_assign(&mut self, other: &VectorPoint<M2>)

Performs the /= operation. Read more
Source§

impl<M> DivAssign<f64> for VectorPoint<M>
where M: Clone,

Source§

fn div_assign(&mut self, other: f64)

Performs the /= operation. Read more
Source§

impl<M> From<&Point> for VectorPoint<M>
where M: Clone,

Source§

fn from(p: &Point) -> VectorPoint<M>

Converts to this type from the input type.
Source§

impl<M> From<&Point3D> for VectorPoint<M>
where M: Clone,

Source§

fn from(p: &Point3D) -> VectorPoint<M>

Converts to this type from the input type.
Source§

impl<M> From<Point> for VectorPoint<M>
where M: Clone,

Source§

fn from(p: Point) -> VectorPoint<M>

Converts to this type from the input type.
Source§

impl<M> From<Point3D> for VectorPoint<M>
where M: Clone,

Source§

fn from(p: Point3D) -> VectorPoint<M>

Converts to this type from the input type.
Source§

impl<M> GetM<M> for VectorPoint<M>
where M: Clone,

Source§

fn m(&self) -> Option<&M>

Returns the m value
Source§

impl<M> GetXY for VectorPoint<M>
where M: Clone,

Source§

fn x(&self) -> f64

Returns the x value
Source§

fn y(&self) -> f64

Returns the y value
Source§

impl<M> GetZ for VectorPoint<M>
where M: Clone,

Source§

fn z(&self) -> f64

Returns the z value
Source§

impl<M1, M2> Mul<&VectorPoint<M2>> for &VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

type Output = VectorPoint<M1>

The resulting type after applying the * operator.
Source§

fn mul( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Mul<&VectorPoint<M2>>>::Output

Performs the * operation. Read more
Source§

impl<M> Mul<f64> for &VectorPoint<M>
where M: Clone,

Source§

type Output = VectorPoint<M>

The resulting type after applying the * operator.
Source§

fn mul(self, other: f64) -> <&VectorPoint<M> as Mul<f64>>::Output

Performs the * operation. Read more
Source§

impl<M1, M2> MulAssign<&VectorPoint<M2>> for VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

fn mul_assign(&mut self, other: &VectorPoint<M2>)

Performs the *= operation. Read more
Source§

impl<M> MulAssign<f64> for VectorPoint<M>
where M: Clone,

Source§

fn mul_assign(&mut self, other: f64)

Performs the *= operation. Read more
Source§

impl<M> Neg for &VectorPoint<M>
where M: Clone,

Source§

type Output = VectorPoint<M>

The resulting type after applying the - operator.
Source§

fn neg(self) -> <&VectorPoint<M> as Neg>::Output

Performs the unary - operation. Read more
Source§

impl<M> Ord for VectorPoint<M>
where M: Clone,

Source§

fn cmp(&self, other: &VectorPoint<M>) -> Ordering

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

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

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

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

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

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

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

impl<M> PartialEq for VectorPoint<M>
where M: Clone,

Source§

fn eq(&self, other: &VectorPoint<M>) -> bool

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

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<M> PartialOrd for VectorPoint<M>
where M: Clone,

Source§

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

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

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

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

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 · Source§

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

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

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<M> Rem<f64> for VectorPoint<M>
where M: Clone,

Source§

type Output = VectorPoint<M>

The resulting type after applying the % operator.
Source§

fn rem(self, modulus: f64) -> <VectorPoint<M> as Rem<f64>>::Output

Performs the % operation. Read more
Source§

impl<M> RemAssign<f64> for VectorPoint<M>
where M: Clone,

Source§

fn rem_assign(&mut self, modulus: f64)

Performs the %= operation. Read more
Source§

impl<M> Serialize for VectorPoint<M>
where M: Clone + Serialize,

Source§

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

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

impl<M1, M2> Sub<&VectorPoint<M2>> for &VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

type Output = VectorPoint<M1>

The resulting type after applying the - operator.
Source§

fn sub( self, other: &VectorPoint<M2>, ) -> <&VectorPoint<M1> as Sub<&VectorPoint<M2>>>::Output

Performs the - operation. Read more
Source§

impl<M> Sub<f64> for &VectorPoint<M>
where M: Clone,

Source§

type Output = VectorPoint<M>

The resulting type after applying the - operator.
Source§

fn sub(self, other: f64) -> <&VectorPoint<M> as Sub<f64>>::Output

Performs the - operation. Read more
Source§

impl<M1, M2> SubAssign<&VectorPoint<M2>> for VectorPoint<M1>
where M1: Clone, M2: Clone,

Source§

fn sub_assign(&mut self, other: &VectorPoint<M2>)

Performs the -= operation. Read more
Source§

impl<M> SubAssign<f64> for VectorPoint<M>
where M: Clone,

Source§

fn sub_assign(&mut self, other: f64)

Performs the -= operation. Read more
Source§

impl<M> Eq for VectorPoint<M>
where M: Clone,

Auto Trait Implementations§

§

impl<M> Freeze for VectorPoint<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for VectorPoint<M>
where M: RefUnwindSafe,

§

impl<M> Send for VectorPoint<M>
where M: Send,

§

impl<M> Sync for VectorPoint<M>
where M: Sync,

§

impl<M> Unpin for VectorPoint<M>
where M: Unpin,

§

impl<M> UnwindSafe for VectorPoint<M>
where M: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

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