Struct rust_sc2::geometry::Point2[][src]

pub struct Point2 {
    pub x: f32,
    pub y: f32,
}
Expand description

Point on 2D grid, the most frequently used geometric primitive.

Fields

x: f32y: f32

Implementations

impl Point2[src]

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

Constructs new 2D Point with given coordinates.

pub fn towards(self, other: Self, offset: f32) -> Self[src]

Returns new point with offset towards other on given distance.

pub fn towards_angle(self, angle: f32, offset: f32) -> Self[src]

Returns new point with offset towards given angle on given distance.

pub fn offset(self, x: f32, y: f32) -> Self[src]

Returns new point with given offset.

pub fn circle_intersection(self, other: Self, radius: f32) -> Option<[Self; 2]>[src]

Returns points where circles with centers self and other, and given radius intersect, or None if they aren’t intersect.

pub fn len_squared(self) -> f32[src]

Returns squared length of the vector.

pub fn len(self) -> f32[src]

Returns length of the vector.

pub fn normalize(self) -> Self[src]

Normalizes the vector.

pub fn rotate(self, angle: f32) -> Self[src]

Rotates the vector on given angle.

pub fn rotate90(self, clockwise: bool) -> Self[src]

Fast rotation of the vector on 90 degrees.

pub fn dot(self, other: Self) -> f32[src]

Dot product.

pub fn round(self) -> Self[src]

Returns rounded point.

pub fn floor(self) -> Self[src]

Returns point rounded to closest lower integer.

pub fn ceil(self) -> Self[src]

Returns point rounded to closest greater integer.

pub fn abs(self) -> Self[src]

Returns point with absolute coordinates.

pub fn neighbors4(self) -> [Self; 4][src]

Returns 4 closest neighbors of point.

pub fn neighbors4diagonal(self) -> [Self; 4][src]

Returns 4 closest diagonal neighbors of point.

pub fn neighbors8(self) -> [Self; 8][src]

Returns 8 closest neighbors of point.

pub fn as_tuple(self) -> (f32, f32)[src]

Returns tuple with point’s coordinates.

pub fn to3(self, z: f32) -> Point3[src]

Converts 2D Point to 3D Point using given z value.

Trait Implementations

impl Add<Point2> for Point2[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: Self) -> Self[src]

Performs the + operation. Read more

impl Add<f32> for Point2[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: f32) -> Self[src]

Performs the + operation. Read more

impl AddAssign<Point2> for Point2[src]

fn add_assign(&mut self, other: Self)[src]

Performs the += operation. Read more

impl AddAssign<f32> for Point2[src]

fn add_assign(&mut self, other: f32)[src]

Performs the += operation. Read more

impl Clone for Point2[src]

fn clone(&self) -> Point2[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Point2[src]

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

Formats the value using the given formatter. Read more

impl Default for Point2[src]

fn default() -> Point2[src]

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

impl Div<Point2> for Point2[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, other: Self) -> Self[src]

Performs the / operation. Read more

impl Div<f32> for Point2[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, other: f32) -> Self[src]

Performs the / operation. Read more

impl DivAssign<Point2> for Point2[src]

fn div_assign(&mut self, other: Self)[src]

Performs the /= operation. Read more

impl DivAssign<f32> for Point2[src]

fn div_assign(&mut self, other: f32)[src]

Performs the /= operation. Read more

impl From<&'_ Point2> for Point2[src]

fn from(p: &Point2) -> Self[src]

Performs the conversion.

impl From<&'_ Unit> for Point2[src]

fn from(u: &Unit) -> Self[src]

Performs the conversion.

impl From<(f32, f32)> for Point2[src]

fn from((x, y): (f32, f32)) -> Self[src]

Performs the conversion.

impl From<(usize, usize)> for Point2[src]

fn from((x, y): (usize, usize)) -> Self[src]

Performs the conversion.

impl From<Point3> for Point2[src]

fn from(p3: Point3) -> Self[src]

Performs the conversion.

impl From<Unit> for Point2[src]

fn from(u: Unit) -> Self[src]

Performs the conversion.

impl Hash for Point2[src]

fn hash<H: Hasher>(&self, state: &mut H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

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

impl Mul<Point2> for Point2[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, other: Self) -> Self[src]

Performs the * operation. Read more

impl Mul<f32> for Point2[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, other: f32) -> Self[src]

Performs the * operation. Read more

impl MulAssign<Point2> for Point2[src]

fn mul_assign(&mut self, other: Self)[src]

Performs the *= operation. Read more

impl MulAssign<f32> for Point2[src]

fn mul_assign(&mut self, other: f32)[src]

Performs the *= operation. Read more

impl Neg for Point2[src]

type Output = Self

The resulting type after applying the - operator.

fn neg(self) -> Self[src]

Performs the unary - operation. Read more

impl PartialEq<Point2> for Point2[src]

fn eq(&self, other: &Self) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl Radius for Point2[src]

fn radius(&self) -> f32[src]

Radius for struct

impl Radius for &Point2[src]

fn radius(&self) -> f32[src]

Radius for struct

impl Sub<Point2> for Point2[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, other: Self) -> Self[src]

Performs the - operation. Read more

impl Sub<f32> for Point2[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, other: f32) -> Self[src]

Performs the - operation. Read more

impl SubAssign<Point2> for Point2[src]

fn sub_assign(&mut self, other: Self)[src]

Performs the -= operation. Read more

impl SubAssign<f32> for Point2[src]

fn sub_assign(&mut self, other: f32)[src]

Performs the -= operation. Read more

impl Sum<Point2> for Point2[src]

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self[src]

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

impl Copy for Point2[src]

impl Eq for Point2[src]

Auto Trait Implementations

impl RefUnwindSafe for Point2

impl Send for Point2

impl Sync for Point2

impl Unpin for Point2

impl UnwindSafe for Point2

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> Distance for T where
    T: Into<Point2>, 
[src]

fn distance_squared<P: Into<Point2>>(self, other: P) -> f32[src]

Calculates squared euclidean distance from self to other.

fn distance<P: Into<Point2>>(self, other: P) -> f32[src]

Calculates euclidean distance from self to other.

fn is_closer<P: Into<Point2>>(self, distance: f32, other: P) -> bool[src]

Checks if distance between self and other is less than given distance.

fn is_further<P: Into<Point2>>(self, distance: f32, other: P) -> bool[src]

Checks if distance between self and other is greater than given distance.

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V