Struct bbecs::data_types::point::Point[][src]

pub struct Point {
    pub x: f32,
    pub y: f32,
}

Point that stores a f32 x and y with methods for manipulating the point. Uses Vector math for the methods

Fields

x: f32y: f32

Implementations

impl Point[src]

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

pub fn to_array(&self) -> [f32; 2][src]

Creates an array of the point with x being the first element, and y being the second. This is mostly useful for working with ggez points as they can cast from arrays.

use bbecs::data_types::point::Point;
let location = Point::new(15.0, 7.0);
assert_eq!(location.to_array(), [15.0, 7.0]);

pub fn add(&mut self, other: &Point)[src]

Adds another point to the one being called, mutating itself

use bbecs::data_types::point::Point;
let mut location = Point::new(0.0, 0.0);
let velocity = Point::new(1.0, 2.0);
location.add(&velocity);
assert_eq!(location, Point::new(1.0, 2.0));

pub fn to_perpendicular_left(&self) -> Self[src]

Create a new Point that is perpendicular to the self pointing towards the left

use bbecs::data_types::point::Point;
let velocity = Point::new(10.0, 25.0);
let left_velocity = velocity.to_perpendicular_left();
assert_eq!(left_velocity, Point::new(25.0, -10.0));

pub fn to_perpendicular_right(&self) -> Self[src]

Create a new Point that is perpendicular to the self pointing towards the right

use bbecs::data_types::point::Point;
let velocity = Point::new(10.0, 25.0);
let right_velocity = velocity.to_perpendicular_right();
assert_eq!(right_velocity, Point::new(-25.0, 10.0));

pub fn multiply_scalar(&mut self, scalar: f32)[src]

Multiplies the x and y by a scalar (single f32) and mutates itself

use bbecs::data_types::point::Point;
let mut point = Point::new(1.0, 2.0);
point.multiply_scalar(10.0);
assert_eq!(point, Point::new(10.0, 20.0));

pub fn normalize(&mut self)[src]

Normalize the point, which makes the hypotenuse equal to 1.0

pub fn length(&self) -> f32[src]

Get the length of the Point

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

pub fn rotation(&self) -> f32[src]

Trait Implementations

impl AddAssign<Point> for Point[src]

impl CastComponents<Point> for Components[src]

fn cast_mut(&mut self) -> Result<&mut Vec<Point>>[src]

Cast the components to it’s contained data as long as it is really a point.

use bbecs::components::{Components, CastComponents};
use bbecs::data_types::point::Point;
let mut wrapped_locations = Components::Point(vec![]);
let locations: &mut Vec<Point> = wrapped_locations.cast_mut().unwrap();

impl Clone for Point[src]

impl Copy for Point[src]

impl Debug for Point[src]

impl Default for Point[src]

impl Div<usize> for Point[src]

type Output = Self

The resulting type after applying the / operator.

impl PartialEq<Point> for Point[src]

impl ResourceCast<Point> for Resource[src]

impl ResourceDataLens<Point> for ResourcesData[src]

impl StructuralPartialEq for Point[src]

impl Sub<Point> for Point[src]

type Output = Self

The resulting type after applying the - operator.

impl Sum<Point> for Point[src]

impl WorldMethods<Point> for World[src]

Auto Trait Implementations

impl RefUnwindSafe for Point

impl Send for Point

impl Sync for Point

impl Unpin for Point

impl UnwindSafe for Point

Blanket Implementations

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

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

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: PartialEq<T> + Copy + Any + Debug
[src]

impl<T> SetParameter for T

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.

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