[−][src]Struct bevy::math::prelude::Vec2
A 2-dimensional vector.
Fields
x: f32
y: f32
Implementations
impl Vec2
[src]
pub fn is_nan_mask(self) -> Vec2Mask
[src]
Performs is_nan
on each element of self, returning a Vec2Mask
of the results.
In other words, this computes [x.is_nan(), y.is_nan()]
.
pub fn signum(self) -> Vec2
[src]
Returns a Vec2
with elements representing the sign of self
.
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
NAN
if the number isNAN
pub fn recip(self) -> Vec2
[src]
Returns a Vec2
containing the reciprocal 1.0/n
of each element of self
.
pub fn lerp(self, other: Vec2, s: f32) -> Vec2
[src]
Performs a linear interpolation between self
and other
based on
the value s
.
When s
is 0.0
, the result will be equal to self
. When s
is 1.0
, the result will be equal to other
.
pub fn is_normalized(self) -> bool
[src]
Returns whether self
is length 1.0
or not.
Uses a precision threshold of 1e-6
.
pub fn is_finite(self) -> bool
[src]
Returns true
if, and only if, all elements are finite.
If any element is either NaN
, positive or negative infinity, this will return false
.
pub fn is_nan(self) -> bool
[src]
Returns true
if any elements are NaN
.
pub fn abs_diff_eq(self, other: Vec2, max_abs_diff: f32) -> bool
[src]
Returns true if the absolute difference of all elements between self
and other
is less than or equal to max_abs_diff
.
This can be used to compare if two Vec2
's contain similar elements. It
works best when comparing with a known value. The max_abs_diff
that
should be used used depends on the values being compared against.
For more on floating point comparisons see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
pub fn new(x: f32, y: f32) -> Vec2
[src]
Creates a new Vec2
.
pub const fn zero() -> Vec2
[src]
Creates a Vec2
with all elements set to 0.0
.
pub const fn one() -> Vec2
[src]
Creates a Vec2
with all elements set to 1.0
.
pub const fn unit_x() -> Vec2
[src]
Creates a Vec2
with values [x: 1.0, y: 0.0]
.
pub const fn unit_y() -> Vec2
[src]
Creates a Vec2
with values [x: 0.0, y: 1.0]
.
pub fn splat(v: f32) -> Vec2
[src]
Creates a Vec2
with all elements set to v
.
pub fn extend(self, z: f32) -> Vec3
[src]
Creates a Vec3
from self
and the given z
value.
pub fn dot(self, other: Vec2) -> f32
[src]
Computes the dot product of self
and other
.
pub fn length(self) -> f32
[src]
Computes the length of self
.
pub fn length_squared(self) -> f32
[src]
Computes the squared length of self
.
This is generally faster than Vec2::length()
as it avoids a square
root operation.
pub fn length_recip(self) -> f32
[src]
Computes 1.0 / Vec2::length()
.
For valid results, self
must not be of length zero.
pub fn distance(self, other: Vec2) -> f32
[src]
Computes the Euclidean distance between two points.
pub fn distance_squared(self, other: Vec2) -> f32
[src]
Compute the squared Euclidean distance between two points.
pub fn normalize(self) -> Vec2
[src]
Returns self
normalized to length 1.0.
For valid results, self
must not be of length zero.
pub fn min(self, other: Vec2) -> Vec2
[src]
Returns the vertical minimum of self
and other
.
In other words, this computes
[x: min(x1, x2), y: min(y1, y2)]
,
taking the minimum of each element individually.
pub fn max(self, other: Vec2) -> Vec2
[src]
Returns the vertical maximum of self
and other
.
In other words, this computes
[x: max(x1, x2), y: max(y1, y2)]
,
taking the maximum of each element individually.
pub fn min_element(self) -> f32
[src]
Returns the horizontal minimum of self
's elements.
In other words, this computes min(x, y)
.
pub fn max_element(self) -> f32
[src]
Returns the horizontal maximum of self
's elements.
In other words, this computes max(x, y)
.
pub fn cmpeq(self, other: Vec2) -> Vec2Mask
[src]
Performs a vertical ==
comparison between self
and other
,
returning a Vec2Mask
of the results.
In other words, this computes [x1 == x2, y1 == y2]
.
pub fn cmpne(self, other: Vec2) -> Vec2Mask
[src]
Performs a vertical !=
comparison between self
and other
,
returning a Vec2Mask
of the results.
In other words, this computes [x1 != x2, y1 != y2]
.
pub fn cmpge(self, other: Vec2) -> Vec2Mask
[src]
Performs a vertical >=
comparison between self
and other
,
returning a Vec2Mask
of the results.
In other words, this computes [x1 >= x2, y1 >= y2]
.
pub fn cmpgt(self, other: Vec2) -> Vec2Mask
[src]
Performs a vertical >
comparison between self
and other
,
returning a Vec2Mask
of the results.
In other words, this computes [x1 > x2, y1 > y2]
.
pub fn cmple(self, other: Vec2) -> Vec2Mask
[src]
Performs a vertical <=
comparison between self
and other
,
returning a Vec2Mask
of the results.
In other words, this computes [x1 <= x2, y1 <= y2]
.
pub fn cmplt(self, other: Vec2) -> Vec2Mask
[src]
Performs a vertical <
comparison between self
and other
,
returning a Vec2Mask
of the results.
In other words, this computes [x1 < x2, y1 < y2]
.
pub fn from_slice_unaligned(slice: &[f32]) -> Vec2
[src]
Creates a Vec2
from the first two values in slice
.
Panics
Panics if slice
is less than two elements long.
pub fn write_to_slice_unaligned(self, slice: &mut [f32])
[src]
Writes the elements of self
to the first two elements in slice
.
Panics
Panics if slice
is less than two elements long.
pub fn abs(self) -> Vec2
[src]
Returns a Vec2
containing the absolute value of each element of self
.
pub fn round(self) -> Vec2
[src]
Returns a Vec2
containing the nearest integer to a number for each element of self
.
Round half-way cases away from 0.0.
pub fn floor(self) -> Vec2
[src]
Returns a Vec2
containing the largest integer less than or equal to a number for each
element of self
.
pub fn ceil(self) -> Vec2
[src]
Returns a Vec2
containing the smallest integer greater than or equal to a number for each
element of self
.
pub fn exp(self) -> Vec2
[src]
Returns a Vec2
containing e^self
(the exponential function) for each element of self
.
pub fn powf(self, n: f32) -> Vec2
[src]
Returns a Vec2
containing each element of self
raised to the power of n
.
pub fn perp(self) -> Vec2
[src]
Returns a Vec2
that is equal to self
rotated by 90 degrees.
pub fn perp_dot(self, other: Vec2) -> f32
[src]
The perpendicular dot product of the vector and other
.
pub fn angle_between(self, other: Vec2) -> f32
[src]
Returns the angle between two vectors, in radians.
The vectors do not need to be unit length, but this function does
perform a sqrt
.
Trait Implementations
impl Add<Vec2> for Vec2
[src]
type Output = Vec2
The resulting type after applying the +
operator.
pub fn add(self, other: Vec2) -> Vec2
[src]
impl<T> Add<Vec2> for Size<T> where
T: Reflect + Add<f32, Output = T>,
T: Reflect + Add<f32, Output = T>,
type Output = Size<T>
The resulting type after applying the +
operator.
pub fn add(self, rhs: Vec2) -> <Size<T> as Add<Vec2>>::Output
impl AddAssign<Vec2> for Vec2
[src]
pub fn add_assign(&mut self, other: Vec2)
[src]
impl<T> AddAssign<Vec2> for Size<T> where
T: Reflect + AddAssign<f32>,
T: Reflect + AddAssign<f32>,
pub fn add_assign(&mut self, rhs: Vec2)
impl AsMut<[f32; 2]> for Vec2
[src]
impl AsRef<[f32; 2]> for Vec2
[src]
impl AsVertexFormats for Vec2
pub fn as_vertex_formats() -> &'static [VertexFormat]ⓘ
impl Byteable for Vec2
impl Clone for Vec2
[src]
impl Copy for Vec2
[src]
impl Debug for Vec2
[src]
impl Default for Vec2
[src]
impl<'de> Deserialize<'de> for Vec2
[src]
pub fn deserialize<D>(
deserializer: D
) -> Result<Vec2, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]
deserializer: D
) -> Result<Vec2, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl Display for Vec2
[src]
impl Div<Vec2> for Vec2
[src]
type Output = Vec2
The resulting type after applying the /
operator.
pub fn div(self, other: Vec2) -> Vec2
[src]
impl Div<f32> for Vec2
[src]
type Output = Vec2
The resulting type after applying the /
operator.
pub fn div(self, other: f32) -> Vec2
[src]
impl DivAssign<Vec2> for Vec2
[src]
pub fn div_assign(&mut self, other: Vec2)
[src]
impl DivAssign<f32> for Vec2
[src]
pub fn div_assign(&mut self, other: f32)
[src]
impl From<[f32; 2]> for Vec2
[src]
impl From<(f32, f32)> for Vec2
[src]
impl From<Vec2> for [f32; 2]
[src]
impl From<Vec2> for (f32, f32)
[src]
impl From<Vec3> for Vec2
[src]
pub fn from(v: Vec3) -> Vec2
[src]
Creates a Vec2
from the x
and y
elements of the Vec3
, discarding z
.
impl From<Vec3A> for Vec2
[src]
pub fn from(v: Vec3A) -> Vec2
[src]
Creates a Vec2
from the x
and y
elements of the Vec3A
, discarding z
.
impl From<Vec4> for Vec2
[src]
pub fn from(v: Vec4) -> Vec2
[src]
Creates a Vec2
from the x
and y
elements of the Vec4
, discarding z
.
impl GetTypeRegistration for Vec2
pub fn get_type_registration() -> TypeRegistration
impl Index<usize> for Vec2
[src]
type Output = f32
The returned type after indexing.
pub fn index(&self, index: usize) -> &<Vec2 as Index<usize>>::Output
[src]
impl IndexMut<usize> for Vec2
[src]
impl Mul<Vec2> for Vec2
[src]
type Output = Vec2
The resulting type after applying the *
operator.
pub fn mul(self, other: Vec2) -> Vec2
[src]
impl Mul<Vec2> for Mat2
[src]
type Output = Vec2
The resulting type after applying the *
operator.
pub fn mul(self, other: Vec2) -> Vec2
[src]
impl Mul<f32> for Vec2
[src]
type Output = Vec2
The resulting type after applying the *
operator.
pub fn mul(self, other: f32) -> Vec2
[src]
impl MulAssign<Vec2> for Vec2
[src]
pub fn mul_assign(&mut self, other: Vec2)
[src]
impl MulAssign<f32> for Vec2
[src]
pub fn mul_assign(&mut self, other: f32)
[src]
impl Neg for Vec2
[src]
impl PartialEq<Vec2> for Vec2
[src]
impl PartialOrd<Vec2> for Vec2
[src]
pub fn partial_cmp(&self, other: &Vec2) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Vec2) -> bool
[src]
pub fn le(&self, other: &Vec2) -> bool
[src]
pub fn gt(&self, other: &Vec2) -> bool
[src]
pub fn ge(&self, other: &Vec2) -> bool
[src]
impl<'a> Product<&'a Vec2> for Vec2
[src]
impl Reflect for Vec2
pub fn type_name(&self) -> &str
pub fn any(&self) -> &(dyn Any + 'static)
pub fn any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
pub fn apply(&mut self, value: &(dyn Reflect + 'static))
pub fn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
pub fn reflect_ref(&self) -> ReflectRef<'_>
pub fn reflect_mut(&mut self) -> ReflectMut<'_>
pub fn reflect_hash(&self) -> Option<u64>
pub fn reflect_partial_eq(
&self,
value: &(dyn Reflect + 'static)
) -> Option<bool>
&self,
value: &(dyn Reflect + 'static)
) -> Option<bool>
pub fn serializable(&self) -> Option<Serializable<'_>>
impl RenderResource for Vec2
pub fn resource_type(&self) -> Option<RenderResourceType>
pub fn write_buffer_bytes(&self, buffer: &mut [u8])
pub fn buffer_byte_len(&self) -> Option<usize>
pub fn texture(&self) -> Option<&Handle<Texture>>
impl Serialize for Vec2
[src]
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
[src]
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
impl StructuralPartialEq for Vec2
[src]
impl Sub<Vec2> for Vec2
[src]
type Output = Vec2
The resulting type after applying the -
operator.
pub fn sub(self, other: Vec2) -> Vec2
[src]
impl SubAssign<Vec2> for Vec2
[src]
pub fn sub_assign(&mut self, other: Vec2)
[src]
impl<'a> Sum<&'a Vec2> for Vec2
[src]
impl Vec2Swizzles for Vec2
[src]
pub fn xxxx(self) -> Vec4
[src]
pub fn xxxy(self) -> Vec4
[src]
pub fn xxyx(self) -> Vec4
[src]
pub fn xxyy(self) -> Vec4
[src]
pub fn xyxx(self) -> Vec4
[src]
pub fn xyxy(self) -> Vec4
[src]
pub fn xyyx(self) -> Vec4
[src]
pub fn xyyy(self) -> Vec4
[src]
pub fn yxxx(self) -> Vec4
[src]
pub fn yxxy(self) -> Vec4
[src]
pub fn yxyx(self) -> Vec4
[src]
pub fn yxyy(self) -> Vec4
[src]
pub fn yyxx(self) -> Vec4
[src]
pub fn yyxy(self) -> Vec4
[src]
pub fn yyyx(self) -> Vec4
[src]
pub fn yyyy(self) -> Vec4
[src]
pub fn xxx(self) -> Vec3
[src]
pub fn xxy(self) -> Vec3
[src]
pub fn xyx(self) -> Vec3
[src]
pub fn xyy(self) -> Vec3
[src]
pub fn yxx(self) -> Vec3
[src]
pub fn yxy(self) -> Vec3
[src]
pub fn yyx(self) -> Vec3
[src]
pub fn yyy(self) -> Vec3
[src]
pub fn xx(self) -> Vec2
[src]
pub fn yx(self) -> Vec2
[src]
pub fn yy(self) -> Vec2
[src]
Auto Trait Implementations
impl RefUnwindSafe for Vec2
[src]
impl Send for Vec2
[src]
impl Sync for Vec2
[src]
impl Unpin for Vec2
[src]
impl UnwindSafe for Vec2
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> AsBytes for T where
T: Byteable,
T: Byteable,
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> Bytes for T where
T: Byteable,
T: Byteable,
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
impl<T> Component for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Send + Sync + Any,
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T> FromBytes for T where
T: Byteable + Clone,
T: Byteable + Clone,
pub fn from_bytes(bytes: &[u8]) -> T
impl<T> FromResources for T where
T: Default,
T: Default,
pub fn from_resources(_resources: &Resources) -> T
impl<T> GetPath for T where
T: Reflect,
T: Reflect,
pub fn path(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
pub fn path_mut(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
pub fn get_path<T>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>> where
T: Reflect,
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>> where
T: Reflect,
pub fn get_path_mut<T>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>> where
T: Reflect,
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>> where
T: Reflect,
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]
T: Serialize + ?Sized,
pub fn erased_serialize(
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
[src]
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
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<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<T> TypeData for T where
T: 'static + Send + Sync + Clone,
T: 'static + Send + Sync + Clone,
pub fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,