Struct bbecs::data_types::point::Point [−][src]
Point that stores a f32 x and y with methods for manipulating the point. Uses Vector math for the methods
Fields
x: f32
y: 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]
fn add_assign(&mut self, rhs: Self)
[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();
fn cast(&self) -> Result<&Vec<Point>>
[src]
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.
fn div(self, rhs: usize) -> Self::Output
[src]
impl PartialEq<Point> for Point
[src]
impl ResourceCast<Point> for Resource
[src]
impl ResourceDataLens<Point> for ResourcesData
[src]
fn get(&self, name: &str) -> Result<&Point>
[src]
fn get_mut(&mut self, name: &str) -> Result<&mut Point>
[src]
impl StructuralPartialEq for Point
[src]
impl Sub<Point> for Point
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
impl Sum<Point> for Point
[src]
impl WorldMethods<Point> for World
[src]
fn with_component<S: Into<String>>(
&mut self,
name: S,
data: Point
) -> Result<&mut Self>
[src]
&mut self,
name: S,
data: Point
) -> Result<&mut Self>
fn add_resource<S: Into<String>>(&mut self, name: S, data: Point)
[src]
fn get_resource<S: Into<String>>(&self, name: S) -> Result<&Point>
[src]
fn get_resource_mut<S: Into<String>>(&mut self, name: S) -> Result<&mut Point>
[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]
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<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]
T: PartialEq<T> + Copy + Any + Debug,
impl<T> SetParameter for T
pub fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub unsafe fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
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, 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>,
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]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,