VectorPoint

Struct VectorPoint 

Source
#[repr(C)]
pub struct VectorPoint<M: Clone = MValue> { 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 coordinate
  • y: Y coordinate
  • z: Z coordinate or “altitude”. May be None
  • m: M-Value
  • t: T for tolerance. A tmp value often used for simplification if needed.

§Usage

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

Source

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

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

Source

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

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

Source§

impl<M: Clone> VectorPoint<M>

Source

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

Create a new point

Source

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

Create a new point with xy

Source

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

Create a new point with xyz

Source

pub fn to_m_value(&self) -> VectorPoint<MValue>
where M: Into<MValue>,

Convert to an MValue VectorPoint

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) -> Self

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

Source

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

Get the cross product of two Vector Points

Source

pub fn dot<M2: Clone>(&self, b: &VectorPoint<M2>) -> 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

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

Returns the intermediate point between this and the other point.

Source

pub fn perpendicular(&self) -> Self

Returns the perpendicular vector

Trait Implementations§

Source§

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

Source§

type Output = VectorPoint<M1>

The resulting type after applying the + operator.
Source§

fn add(self, other: &VectorPoint<M2>) -> Self::Output

Performs the + operation. Read more
Source§

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

Source§

type Output = VectorPoint<M>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

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

Source§

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

Performs the += operation. Read more
Source§

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

Source§

fn add_assign(&mut self, other: f64)

Performs the += operation. Read more
Source§

impl<M: Clone + Clone> Clone for VectorPoint<M>

Source§

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

Returns a duplicate 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 + Clone> Debug for VectorPoint<M>

Source§

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

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

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

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: Deserialize<'de> + Clone,

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<M1: Clone, M2: Clone> Div<&VectorPoint<M2>> for &VectorPoint<M1>

Source§

type Output = VectorPoint<M1>

The resulting type after applying the / operator.
Source§

fn div(self, other: &VectorPoint<M2>) -> Self::Output

Performs the / operation. Read more
Source§

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

Source§

type Output = VectorPoint<M>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

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

Source§

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

Performs the /= operation. Read more
Source§

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

Source§

fn div_assign(&mut self, other: f64)

Performs the /= operation. Read more
Source§

impl<M: Clone, P: GetXYZ> From<&P> for VectorPoint<M>

Source§

fn from(p: &P) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(p: Point) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(p: Point3D) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Returns the m value
Source§

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

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<M: Clone> GetZ for VectorPoint<M>

Source§

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

Returns the z value
Source§

impl<M: Interpolate + Clone> Interpolate for VectorPoint<M>

Source§

fn interpolate(&self, other: &Self, t: f64) -> Self

Interpolate between two of the same type
Source§

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

Source§

type Output = VectorPoint<M1>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &VectorPoint<M2>) -> Self::Output

Performs the * operation. Read more
Source§

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

Source§

type Output = VectorPoint<M>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

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

Source§

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

Performs the *= operation. Read more
Source§

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

Source§

fn mul_assign(&mut self, other: f64)

Performs the *= operation. Read more
Source§

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

Source§

type Output = VectorPoint<M>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<M: Clone> NewXY for VectorPoint<M>

Source§

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

Create a new point with xy
Source§

impl<M: Clone> NewXYM<M> for VectorPoint<M>

Source§

fn new_xym(x: f64, y: f64, m: M) -> Self

Create a new point with xy
Source§

impl<M: Clone> NewXYZ for VectorPoint<M>

Source§

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

Create a new point with xyz
Source§

impl<M: Clone> NewXYZM<M> for VectorPoint<M>

Source§

fn new_xyzm(x: f64, y: f64, z: f64, m: M) -> Self

Create a new point with xyzm
Source§

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

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: Clone> PartialEq for VectorPoint<M>

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

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

Source§

type Output = VectorPoint<M>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

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

Source§

fn rem_assign(&mut self, modulus: f64)

Performs the %= operation. Read more
Source§

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

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<M: Clone> SetM<M> for VectorPoint<M>

Source§

fn set_m(&mut self, m: M)

Set the m value
Source§

impl<M: Clone> SetXY for VectorPoint<M>

Source§

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

Set both x and y
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§

impl<M: Clone> SetZ for VectorPoint<M>

Source§

fn set_z(&mut self, z: f64)

Set the z value
Source§

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

Source§

type Output = VectorPoint<M1>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &VectorPoint<M2>) -> Self::Output

Performs the - operation. Read more
Source§

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

Source§

type Output = VectorPoint<M>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

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

Source§

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

Performs the -= operation. Read more
Source§

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

Source§

fn sub_assign(&mut self, other: f64)

Performs the -= operation. Read more
Source§

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

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, M> SetXYM<M> for T
where T: SetXY + SetM<M>,

Source§

fn set_xym(&mut self, x: f64, y: f64, m: M)

Set x, y and m
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
Source§

impl<T, M> SetXYZM<M> for T
where T: SetXY + SetZ + SetM<M>,

Source§

fn set_xyzm(&mut self, x: f64, y: f64, z: f64, m: M)

Set x, y, z and m
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>,

Source§

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

Source§

impl<T, M> FullXYM<M> for T
where T: GetXYZM<M> + SetXYM<M> + NewXYM<M> + Clone + PartialEq + Ord,

Source§

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

Source§

impl<T, M> FullXYZM<M> for T
where T: GetXYZM<M> + SetXYZM<M> + NewXYZM<M> + Clone + PartialEq + Ord,

Source§

impl<T, M> GetXYM<M> for T
where T: GetXY + GetM<M>,

Source§

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

Source§

impl<T, M> GetXYZM<M> for T
where T: GetXY + GetZ + GetM<M>,