Struct libreda_db::layout::prelude::Point [−][src]
A point is defined by a x and y coordinate in the euclidean plane.
Implementations
impl<T> Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
pub fn new(x: T, y: T) -> Point<T>
[src]
Create a new point with x
and y
coordinates.
pub fn zero() -> Point<T>
[src]
Get zero-Point.
Examples
use iron_shapes::point::Point; let a = Point::zero(); let b = Point::new(0, 0); assert_eq!(a, b);
pub fn is_zero(&self) -> bool
[src]
Check if this is the zero-Point.
Examples
use iron_shapes::point::*; assert!(Point::<usize>::zero().is_zero());
pub fn distance_sq(self, other: &Point<T>) -> T
[src]
Compute the squared distance to the other
point.
Examples
use iron_shapes::point::*; let a = Point::new(0, 0); let b = Point::new(2, 0); assert_eq!(a.distance_sq(&b), 2*2);
pub fn cross_prod3(&self, b: Point<T>, c: Point<T>) -> T
[src]
Calculate the cross product of the two vectors defined by three points.
A positive value implies that self
→ a
→ b
is counter-clockwise, negative implies
clockwise.
(b
- self
) x (c
- b
)
Examples
use iron_shapes::point::Point; let a = Point::new(1,0); let b = Point::new(1,1); let c = Point::new(0,1); let p = a.cross_prod3(b, c); assert_eq!(p, (b-a).cross_prod(c - b));
pub fn v(&self) -> Vector<T>
[src]
Return the location of this point as a vector.
impl<T> Point<T> where
T: CoordinateType + NumCast,
[src]
T: CoordinateType + NumCast,
pub fn distance<F>(self, other: &Point<T>) -> F where
F: Float,
[src]
F: Float,
Compute the Euclidean distance betwen two points.
impl<T> Point<T> where
T: CoordinateType + NumCast,
[src]
T: CoordinateType + NumCast,
pub fn cast_to_float<F>(&self) -> Point<F> where
F: CoordinateType + NumCast + Float,
[src]
F: CoordinateType + NumCast + Float,
Convert Point into a Point with floating point data type.
Methods from Deref<Target = Vector<T>>
pub fn norm1(&self) -> T
[src]
Get 1-norm of vector, i.e. the sum of the absolute values of its components.
Examples
use iron_shapes::vector::Vector; let a = Vector::new(-2, 3); assert_eq!(a.norm1(), 5);
pub fn norm2_squared(&self) -> T
[src]
Get squared 2-norm of vector.
Examples
use iron_shapes::vector::Vector; let a = Vector::new(2, 3); assert_eq!(a.norm2_squared(), 2*2+3*3);
pub fn dot(&self, other: Vector<T>) -> T
[src]
Calculate scalar product.
Examples
use iron_shapes::vector::Vector; let a = Vector::new(1, 2); let b = Vector::new(3, 4); assert_eq!(a.dot(b), 1*3 + 2*4);
pub fn cross_prod(&self, other: Vector<T>) -> T
[src]
Calculate cross product.
Examples
use iron_shapes::vector::Vector; let a = Vector::new(2, 0); let b = Vector::new(0, 2); assert_eq!(a.cross_prod(b), 4); assert_eq!(b.cross_prod(a), -4);
pub fn orientation_of(&self, other: Vector<T>) -> Orientation
[src]
Check if other
is oriented clockwise or counter-clockwise respective to self
.
Examples
use iron_shapes::vector::Vector; use iron_shapes::types::Orientation; let a = Vector::new(1, 0); let b = Vector::new(1, 1); let c = Vector::new(1, -1); let d = Vector::new(2, 0); assert_eq!(a.orientation_of(b), Orientation::CounterClockWise); assert_eq!(a.orientation_of(c), Orientation::ClockWise); assert_eq!(a.orientation_of(d), Orientation::Straight);
pub fn cast_to_float<F>(&self) -> Vector<F> where
F: CoordinateType + NumCast + Float,
[src]
F: CoordinateType + NumCast + Float,
Convert vector into a vector with floating point data type.
pub fn norm2(&self) -> T
[src]
Get 2-norm of vector (length of vector).
Examples
use iron_shapes::vector::Vector; let a = Vector::new(2.0, 3.0); let norm2 = a.norm2(); let norm2_sq = norm2 * norm2; let expected = a.norm2_squared(); assert!(norm2_sq < expected + 1e-12); assert!(norm2_sq > expected - 1e-12);
pub fn normalized(&self) -> Vector<T>
[src]
pub fn normal(&self) -> Vector<T>
[src]
Return the normal vector onto this vector. The normal has length 0.
Panics
Panics if the vector has length 0.
pub fn length<F>(&self) -> F where
F: Float,
[src]
F: Float,
Calculate length of vector.
Similar to Vector::norm2
but does potentially return another data type for the length.
Examples
use iron_shapes::vector::Vector; let a = Vector::new(2.0, 3.0); let length: f64 = a.length(); let norm2_sq = length * length; let expected = a.norm2_squared(); assert!(norm2_sq < expected + 1e-12); assert!(norm2_sq > expected - 1e-12);
Trait Implementations
impl<T, V> Add<V> for Point<T> where
T: CoordinateType<Output = T> + Add<T>,
V: Into<Point<T>>,
[src]
T: CoordinateType<Output = T> + Add<T>,
V: Into<Point<T>>,
Point addition.
type Output = Point<T>
The resulting type after applying the +
operator.
pub fn add(self, rhs: V) -> Point<T>
[src]
impl<T, V> AddAssign<V> for Point<T> where
T: CoordinateType + AddAssign<T>,
V: Into<Vector<T>>,
[src]
T: CoordinateType + AddAssign<T>,
V: Into<Vector<T>>,
pub fn add_assign(&mut self, rhs: V)
[src]
impl<T> Clone for Point<T> where
T: Clone + CoordinateType,
[src]
T: Clone + CoordinateType,
impl<T> Copy for Point<T> where
T: Copy + CoordinateType,
[src]
T: Copy + CoordinateType,
impl<T> Debug for Point<T> where
T: Debug + CoordinateType,
[src]
T: Debug + CoordinateType,
impl<T> Default for Point<T> where
T: Default + CoordinateType,
[src]
T: Default + CoordinateType,
impl<T> Deref for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
type Target = Vector<T>
The resulting type after dereferencing.
pub fn deref(&self) -> &<Point<T> as Deref>::Target
[src]
impl<T> Display for Point<T> where
T: Display + CoordinateType,
[src]
T: Display + CoordinateType,
impl<T> Div<T> for Point<T> where
T: CoordinateType<Output = T> + Div<T>,
[src]
T: CoordinateType<Output = T> + Div<T>,
Scalar division.
type Output = Point<T>
The resulting type after applying the /
operator.
pub fn div(self, rhs: T) -> Point<T>
[src]
impl<T> Eq for Point<T> where
T: Eq + CoordinateType,
[src]
T: Eq + CoordinateType,
impl<'_, T> From<&'_ Vector<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<'a, T> From<&'a (T, T)> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<'a, T> From<&'a Point<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> From<[T; 2]> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> From<(T, T)> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> From<Point<T>> for Geometry<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> From<Vector<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Hash for Point<T> where
T: Hash + CoordinateType,
[src]
T: Hash + CoordinateType,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Into<(T, T)> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<'_, T> Into<(T, T)> for &'_ Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Into<Vector<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> MapPointwise<T> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
Point wise transformation for a single point.
pub fn transform<F>(&self, transformation: F) -> Point<T> where
F: Fn(Point<T>) -> Point<T>,
[src]
F: Fn(Point<T>) -> Point<T>,
Point wise transformation.
impl<T> Mul<T> for Point<T> where
T: CoordinateType<Output = T> + Mul<T>,
[src]
T: CoordinateType<Output = T> + Mul<T>,
Scalar multiplication.
type Output = Point<T>
The resulting type after applying the *
operator.
pub fn mul(self, rhs: T) -> Point<T>
[src]
impl<T> MulAssign<T> for Point<T> where
T: CoordinateType + MulAssign<T>,
[src]
T: CoordinateType + MulAssign<T>,
In-place scalar multiplication.
pub fn mul_assign(&mut self, rhs: T)
[src]
impl<T> Neg for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
type Output = Point<T>
The resulting type after applying the -
operator.
pub fn neg(self) -> Point<T>
[src]
impl<T> Ord for Point<T> where
T: CoordinateType + Ord,
[src]
T: CoordinateType + Ord,
Compare points.
The ordering is determined by the x-coordinates. If it is the same for both points the y-coordinate is used.
Point a
> Point b
iff a.x > b.x || (a.x == b.x && a.y > b.y)
.
pub fn cmp(&self, rhs: &Point<T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T> PartialEq<Point<T>> for Point<T> where
T: PartialEq<T> + CoordinateType,
[src]
T: PartialEq<T> + CoordinateType,
impl<T> PartialOrd<Point<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
Compare points.
The ordering is determined by the x-coordinates. If it is the same for both points the y-coordinate is used.
Point a
> Point b
iff a.x > b.x || (a.x == b.x && a.y > b.y)
.
pub fn partial_cmp(&self, rhs: &Point<T>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T> StructuralEq for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> StructuralPartialEq for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
impl<T> Sub<Point<T>> for Point<T> where
T: CoordinateType<Output = T> + Sub<T>,
[src]
T: CoordinateType<Output = T> + Sub<T>,
Subtract a point.
type Output = Vector<T>
The resulting type after applying the -
operator.
pub fn sub(self, rhs: Point<T>) -> <Point<T> as Sub<Point<T>>>::Output
[src]
impl<T> Sub<Vector<T>> for Point<T> where
T: CoordinateType<Output = T> + Sub<T>,
[src]
T: CoordinateType<Output = T> + Sub<T>,
Subtract a vector.
type Output = Point<T>
The resulting type after applying the -
operator.
pub fn sub(self, rhs: Vector<T>) -> <Point<T> as Sub<Vector<T>>>::Output
[src]
impl<T, V> SubAssign<V> for Point<T> where
T: CoordinateType + SubAssign<T>,
V: Into<Vector<T>>,
[src]
T: CoordinateType + SubAssign<T>,
V: Into<Vector<T>>,
pub fn sub_assign(&mut self, rhs: V)
[src]
impl<T> Sum<Point<T>> for Point<T> where
T: CoordinateType,
[src]
T: CoordinateType,
pub fn sum<I>(iter: I) -> Point<T> where
I: Iterator<Item = Point<T>>,
[src]
I: Iterator<Item = Point<T>>,
Compute the sum of all points in the iterator. If the iterator is empty, (0, 0) is returned.
impl<T, Dst> TryCastCoord<T, Dst> for Point<T> where
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
[src]
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
Auto Trait Implementations
impl<T> RefUnwindSafe for Point<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Point<T> where
T: Send,
T: Send,
impl<T> Sync for Point<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Point<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Point<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<S, T> Mirror<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
[src]
S: MapPointwise<T>,
T: CoordinateType,
pub fn mirror_x(&self) -> S
[src]
Return the geometrical object mirrored at the x
axis.
pub fn mirror_y(&self) -> S
[src]
Return the geometrical object mirrored at the y
axis.
impl<S, T> RotateOrtho<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
[src]
S: MapPointwise<T>,
T: CoordinateType,
pub fn rotate_ortho(&self, a: Angle) -> S
[src]
impl<S, T> Scale<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
[src]
S: MapPointwise<T>,
T: CoordinateType,
impl<T> TextType for T where
T: Clone + Eq + Debug + Hash,
[src]
T: Clone + Eq + Debug + Hash,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<S, T> Translate<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
[src]
S: MapPointwise<T>,
T: CoordinateType,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,