Struct libreda_pnr::db::Point[−][src]

pub struct Point<T> { /* fields omitted */ }
Expand description

A point is defined by a x and y coordinate in the euclidean plane.

Implementations

Create a new point with x and y coordinates.

Return the location of this point as a vector.

Get zero-Point.

Examples
use iron_shapes::point::Point;

let a = Point::zero();
let b = Point::new(0, 0);

assert_eq!(a, b);

Check if this is the zero-Point.

Examples
use iron_shapes::point::*;

assert!(Point::<usize>::zero().is_zero());

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

Calculate the cross product of the two vectors defined by three points.

A positive value implies that selfab 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));

Compute the Euclidean distance betwen two points.

Convert Point into a Point with floating point data type.

Methods from Deref<Target = Vector<T>>

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

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

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

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

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

Convert vector into a vector with floating point data type.

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

Return a vector with the same direction but length 1.

Panics

Panics if the vector has length 0.

Return the normal vector onto this vector. The normal has length 0.

Panics

Panics if the vector has length 0.

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

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Return the bounding box of this geometry.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Scalar division.

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Point wise transformation for a single point.

Point wise transformation.

Scalar multiplication.

The resulting type after applying the * operator.

Performs the * operation. Read more

In-place scalar multiplication.

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Subtract a point.

The resulting type after applying the - operator.

Performs the - operation. Read more

Subtract a vector.

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Compute the sum of all points in the iterator. If the iterator is empty, (0, 0) is returned.

Return the bounding box of this geometry if a bounding box is defined.

Output type of the cast. This is likely the same geometrical type just with other coordinate types. Read more

Try to cast to target data type. Read more

Cast to target data type. Read more

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Return the geometrical object mirrored at the x axis.

Return the geometrical object mirrored at the y axis.

Rotate the geometrical shape by a multiple of 90 degrees.

Scale the geometrical shape. Scaling center is the origin (0, 0).

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

Translate the geometrical object by a vector v.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.