Struct euclid::point::TypedPoint2D
[−]
[src]
#[repr(C)]pub struct TypedPoint2D<T, U> { pub x: T, pub y: T, // some fields omitted }
A 2d Point tagged with a unit.
Fields
x: T
y: T
Methods
impl<T: Copy + Zero, U> TypedPoint2D<T, U>
[src]
fn zero() -> TypedPoint2D<T, U>
Constructor, setting all components to zero.
fn to_3d(&self) -> TypedPoint3D<T, U>
Convert into a 3d point.
impl<T: Copy, U> TypedPoint2D<T, U>
[src]
fn new(x: T, y: T) -> TypedPoint2D<T, U>
Constructor taking scalar values directly.
fn from_lengths(x: Length<T, U>, y: Length<T, U>) -> TypedPoint2D<T, U>
Constructor taking properly typed Lengths instead of scalar values.
fn x_typed(&self) -> Length<T, U>
Returns self.x as a Length carrying the unit.
fn y_typed(&self) -> Length<T, U>
Returns self.y as a Length carrying the unit.
fn to_untyped(&self) -> Point2D<T>
Drop the units, preserving only the numeric value.
fn from_untyped(p: &Point2D<T>) -> TypedPoint2D<T, U>
Tag a unitless value with units.
fn to_array(&self) -> [T; 2]
impl<T, U> TypedPoint2D<T, U> where
T: Copy + Mul<T, Output = T> + Add<T, Output = T> + Sub<T, Output = T>,
[src]
T: Copy + Mul<T, Output = T> + Add<T, Output = T> + Sub<T, Output = T>,
fn dot(self, other: TypedPoint2D<T, U>) -> T
Dot product.
fn cross(self, other: TypedPoint2D<T, U>) -> T
Returns the norm of the cross product [self.x, self.y, 0] x [other.x, other.y, 0]..
fn normalize(self) -> Self where
T: Float + ApproxEq<T>,
T: Float + ApproxEq<T>,
impl<T: Copy + Add<T, Output = T>, U> TypedPoint2D<T, U>
[src]
fn add_size(&self, other: &TypedSize2D<T, U>) -> TypedPoint2D<T, U>
impl<T: Float, U> TypedPoint2D<T, U>
[src]
fn min(self, other: TypedPoint2D<T, U>) -> TypedPoint2D<T, U>
fn max(self, other: TypedPoint2D<T, U>) -> TypedPoint2D<T, U>
impl<T: Round, U> TypedPoint2D<T, U>
[src]
fn round(&self) -> Self
Rounds each component to the nearest integer value.
This behavior is preserved for negative values (unlike the basic cast).
For example { -0.1, -0.8 }.round() == { 0.0, -1.0 }
.
impl<T: Ceil, U> TypedPoint2D<T, U>
[src]
fn ceil(&self) -> Self
Rounds each component to the smallest integer equal or greater than the original value.
This behavior is preserved for negative values (unlike the basic cast).
For example { -0.1, -0.8 }.ceil() == { 0.0, 0.0 }
.
impl<T: Floor, U> TypedPoint2D<T, U>
[src]
fn floor(&self) -> Self
Rounds each component to the biggest integer equal or lower than the original value.
This behavior is preserved for negative values (unlike the basic cast).
For example { -0.1, -0.8 }.floor() == { -1.0, -1.0 }
.
impl<T: NumCast + Copy, U> TypedPoint2D<T, U>
[src]
fn cast<NewT: NumCast + Copy>(&self) -> Option<TypedPoint2D<NewT, U>>
Cast from one numeric representation to another, preserving the units.
When casting from floating point to integer coordinates, the decimals are truncated
as one would expect from a simple cast, but this behavior does not always make sense
geometrically. Consider using round()
, ceil()
or floor()
before casting.
fn to_f32(&self) -> TypedPoint2D<f32, U>
Cast into an f32
point.
fn to_uint(&self) -> TypedPoint2D<usize, U>
Cast into an usize
point, truncating decimals if any.
When casting from floating point points, it is worth considering whether
to round()
, ceil()
or floor()
before the cast in order to obtain
the desired conversion behavior.
fn to_i32(&self) -> TypedPoint2D<i32, U>
Cast into an i32 point, truncating decimals if any.
When casting from floating point points, it is worth considering whether
to round()
, ceil()
or floor()
before the cast in order to obtain
the desired conversion behavior.
fn to_i64(&self) -> TypedPoint2D<i64, U>
Cast into an i64 point, truncating decimals if any.
When casting from floating point points, it is worth considering whether
to round()
, ceil()
or floor()
before the cast in order to obtain
the desired conversion behavior.
Trait Implementations
impl<T: Decodable, U: Decodable> Decodable for TypedPoint2D<T, U>
[src]
fn decode<__DTU: Decoder>(
__arg_0: &mut __DTU
) -> Result<TypedPoint2D<T, U>, __DTU::Error>
__arg_0: &mut __DTU
) -> Result<TypedPoint2D<T, U>, __DTU::Error>
Deserialize a value using a Decoder
.
impl<T: Encodable, U: Encodable> Encodable for TypedPoint2D<T, U>
[src]
fn encode<__STU: Encoder>(
&self,
__arg_0: &mut __STU
) -> Result<(), __STU::Error>
&self,
__arg_0: &mut __STU
) -> Result<(), __STU::Error>
Serialize a value using an Encoder
.
impl<T: Clone, U> Clone for TypedPoint2D<T, U>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Copy, U> Copy for TypedPoint2D<T, U>
[src]
impl<T, U> HeapSizeOf for TypedPoint2D<T, U> where
T: HeapSizeOf,
[src]
T: HeapSizeOf,
fn heap_size_of_children(&self) -> usize
Measure the size of any heap-allocated structures that hang off this value, but not the space taken up by the value itself (i.e. what size_of:: measures, more or less); that space is handled by the implementation of HeapSizeOf for Box below. Read more
impl<T, U> Deserialize for TypedPoint2D<T, U> where
T: Deserialize,
[src]
T: Deserialize,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer,
D: Deserializer,
Deserialize this value from the given Serde deserializer. Read more
impl<T, U> Serialize for TypedPoint2D<T, U> where
T: Serialize,
[src]
T: Serialize,
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T, U> Eq for TypedPoint2D<T, U> where
T: Eq,
[src]
T: Eq,
impl<T, U> PartialEq for TypedPoint2D<T, U> where
T: PartialEq,
[src]
T: PartialEq,
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<T, U> Hash for TypedPoint2D<T, U> where
T: Hash,
[src]
T: Hash,
fn hash<H: Hasher>(&self, h: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the state provided.
impl<T: Debug, U> Debug for TypedPoint2D<T, U>
[src]
impl<T: Display, U> Display for TypedPoint2D<T, U>
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Copy + Add<T, Output = T>, U> Add for TypedPoint2D<T, U>
[src]
type Output = TypedPoint2D<T, U>
The resulting type after applying the +
operator
fn add(self, other: TypedPoint2D<T, U>) -> TypedPoint2D<T, U>
The method for the +
operator
impl<T: Copy + Add<T, Output = T>, U> Add<TypedSize2D<T, U>> for TypedPoint2D<T, U>
[src]
type Output = TypedPoint2D<T, U>
The resulting type after applying the +
operator
fn add(self, other: TypedSize2D<T, U>) -> TypedPoint2D<T, U>
The method for the +
operator
impl<T: Copy + Sub<T, Output = T>, U> Sub for TypedPoint2D<T, U>
[src]
type Output = TypedPoint2D<T, U>
The resulting type after applying the -
operator
fn sub(self, other: TypedPoint2D<T, U>) -> TypedPoint2D<T, U>
The method for the -
operator
impl<T: Copy + Neg<Output = T>, U> Neg for TypedPoint2D<T, U>
[src]
type Output = TypedPoint2D<T, U>
The resulting type after applying the -
operator
fn neg(self) -> TypedPoint2D<T, U>
The method for the unary -
operator
impl<T: Copy + Mul<T, Output = T>, U> Mul<T> for TypedPoint2D<T, U>
[src]
type Output = TypedPoint2D<T, U>
The resulting type after applying the *
operator
fn mul(self, scale: T) -> TypedPoint2D<T, U>
The method for the *
operator
impl<T: Copy + Div<T, Output = T>, U> Div<T> for TypedPoint2D<T, U>
[src]
type Output = TypedPoint2D<T, U>
The resulting type after applying the /
operator
fn div(self, scale: T) -> TypedPoint2D<T, U>
The method for the /
operator
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<ScaleFactor<T, U1, U2>> for TypedPoint2D<T, U1>
[src]
type Output = TypedPoint2D<T, U2>
The resulting type after applying the *
operator
fn mul(self, scale: ScaleFactor<T, U1, U2>) -> TypedPoint2D<T, U2>
The method for the *
operator
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<ScaleFactor<T, U1, U2>> for TypedPoint2D<T, U2>
[src]
type Output = TypedPoint2D<T, U1>
The resulting type after applying the /
operator
fn div(self, scale: ScaleFactor<T, U1, U2>) -> TypedPoint2D<T, U1>
The method for the /
operator