Skip to main content

RawPoint

Struct RawPoint 

Source
pub struct RawPoint {
    pub components: [f32; 2],
}
Expand description

A point (or vector) in 2D map coordinates.

RawPoint supports component-wise arithmetic: Mul, Div, MulAssign and DivAssign with f32 and the common integer types, and Add/Sub with other points (by value or by reference). It also converts from and to [f32; 2], integer arrays and egui::Pos2.

§Examples

use egui_map::map::objects::RawPoint;

let a = RawPoint::new(1.0, 2.0);
let b = RawPoint::new(3.0, -1.0);

assert_eq!((a + b).components, [4.0, 1.0]);
assert_eq!((a * 2.0f32).components, [2.0, 4.0]);

Fields§

§components: [f32; 2]

The x and y components of the point.

Implementations§

Source§

impl RawPoint

Source

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

Creates a point from its x and y coordinates.

Trait Implementations§

Source§

impl Add for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the + operator.
Source§

fn add(self, rhs: RawPoint) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&RawPoint> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &RawPoint) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for RawPoint

Source§

fn clone(&self) -> RawPoint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for RawPoint

Source§

impl Debug for RawPoint

Source§

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

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

impl Default for RawPoint

Source§

fn default() -> Self

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

impl Div<f32> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i32> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i64> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u32> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u64> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<f32> for RawPoint

Source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
Source§

impl DivAssign<i32> for RawPoint

Source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
Source§

impl DivAssign<i64> for RawPoint

Source§

fn div_assign(&mut self, rhs: i64)

Performs the /= operation. Read more
Source§

impl DivAssign<u32> for RawPoint

Source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
Source§

impl DivAssign<u64> for RawPoint

Source§

fn div_assign(&mut self, rhs: u64)

Performs the /= operation. Read more
Source§

impl From<Pos2> for RawPoint

Source§

fn from(value: Pos2) -> Self

Converts to this type from the input type.
Source§

impl From<RawPoint> for [f32; 2]

Source§

fn from(val: RawPoint) -> Self

Converts to this type from the input type.
Source§

impl From<RawPoint> for Pos2

Source§

fn from(val: RawPoint) -> Self

Converts to this type from the input type.
Source§

impl From<[f32; 2]> for RawPoint

Source§

fn from(value: [f32; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[i8; 2]> for RawPoint

Source§

fn from(value: [i8; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[i16; 2]> for RawPoint

Source§

fn from(value: [i16; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[i32; 2]> for RawPoint

Source§

fn from(value: [i32; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[i64; 2]> for RawPoint

Source§

fn from(value: [i64; 2]) -> Self

Converts to this type from the input type.
Source§

impl Mul<f32> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i32> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i64> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u32> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u64> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<f32> for RawPoint

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl MulAssign<i32> for RawPoint

Source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
Source§

impl MulAssign<i64> for RawPoint

Source§

fn mul_assign(&mut self, rhs: i64)

Performs the *= operation. Read more
Source§

impl MulAssign<u32> for RawPoint

Source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
Source§

impl MulAssign<u64> for RawPoint

Source§

fn mul_assign(&mut self, rhs: u64)

Performs the *= operation. Read more
Source§

impl PartialEq for RawPoint

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Point for RawPoint

Source§

const DIMENSIONS: usize = 2

The number of dimensions of this point type.
Source§

type Scalar = f32

The number type used by this point type.
Source§

fn generate(generator: impl FnMut(usize) -> Self::Scalar) -> Self

Creates a new point value with given values for each dimension. Read more
Source§

fn nth(&self, index: usize) -> Self::Scalar

Returns a single coordinate of this point. Read more
Source§

fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar

Mutable variant of nth.
Source§

impl StructuralPartialEq for RawPoint

Source§

impl Sub for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RawPoint) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&RawPoint> for RawPoint

Source§

type Output = RawPoint

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &RawPoint) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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<P> PointDistance for P
where P: Point,

Source§

fn distance_2(&self, point: &P) -> <P as Point>::Scalar

Returns the squared distance between an object and a point. Read more
Source§

fn contains_point( &self, point: &<<P as RTreeObject>::Envelope as Envelope>::Point, ) -> bool

Returns true if a point is contained within this object. Read more
Source§

fn distance_2_if_less_or_equal( &self, point: &<<P as RTreeObject>::Envelope as Envelope>::Point, max_distance_2: <<<P as RTreeObject>::Envelope as Envelope>::Point as Point>::Scalar, ) -> Option<<P as Point>::Scalar>

Returns the squared distance to this object, or None if the distance is larger than a given maximum value. Read more
Source§

impl<P> RTreeObject for P
where P: Point,

Source§

type Envelope = AABB<P>

The object’s envelope type. Usually, AABB will be the right choice. This type also defines the object’s dimensionality.
Source§

fn envelope(&self) -> AABB<P>

Returns the object’s envelope. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.