Struct ludomath::vec2d::Point
[−]
[src]
#[repr(C)]pub struct Point { pub x: f32, pub y: f32, }
Represents a cartesian point in the 2D euclidean plane.
Fields
x: f32
The X coordinate of the point.
y: f32
The Y coordinate of the point.
Methods
impl Point
[src]
pub fn new(x: f32, y: f32) -> Point
[src]
Constructs a new point from x- and y-components.
pub fn new_polar_rad(radius: f32, angle: f32) -> Point
[src]
Constructs a new point from polar coordinates.
The angle is given in radians.
pub fn new_polar_deg(radius: f32, angle: f32) -> Point
[src]
Constructs a new point from polar coordinates.
The angle is given in degrees.
pub fn dist(self, other: Point) -> f32
[src]
Computes the euclidean distance between two points.
pub fn rotate(self, pivot: Point, rotation: Rotation) -> Point
[src]
Rotates a point around a pivot point.
pub fn rotate_rad(self, pivot: Point, angle: f32) -> Point
[src]
Rotates a point angle
radians counter-clockwise around a pivot point.
pub fn rotate_deg(self, pivot: Point, angle: f32) -> Point
[src]
Rotates a point angle
degrees counter-clockwise around a pivot point.
pub fn lerp(self, other: Point, t: f32) -> Point
[src]
Linearly interpolates from one point to another by t
.
t
< 0 or t
> 1 gives results outside the
rectangular bounds of the points.
pub fn is_in_rect(self, vert1: Point, vert2: Point) -> bool
[src]
Returns true
if self
is within the (inclusive) bounds
of the rectangle defined by two points.
pub fn clamp_to_rect(self, vert1: Point, vert2: Point) -> Point
[src]
Clamps a vector to within the (inclusive) bounds of the rectangle defined by two points.
pub fn as_vec(self) -> Vector
[src]
Reinterprets the x- and y-components of a point as a vector.
pub fn from_gl_vec2(vec2: [f32; 2]) -> Point
[src]
Changes the type of a OpenGL-style vec2
array to a Point
.
Optimizes into a simple copy, since the types have the same layout. Useful mostly for interop with other libraries, like OpenGL wrappers.
pub fn to_gl_vec2(self) -> [f32; 2]
[src]
Changes the type of a Point
to a OpenGL-style vec2
array.
Optimizes into a simple copy, since the types have the same layout. Useful mostly for interop with other libraries, like OpenGL wrappers.
pub fn from_vec2(vec2: [f32; 2]) -> Point
[src]
Converts a OpenGL-style vec2
to a Point
.
Optimizes into a simple copy, since the types have the same layout.
pub fn to_vec2(self) -> [f32; 2]
[src]
Converts a Point
to a OpenGL-style vec2
.
Optimizes into a simple copy, since the types have the same layout.
pub fn to_vec3(self) -> [f32; 3]
[src]
Converts a Point
to a OpenGL-style vec3
.
The result is padded to [x, y, 0]
.
pub fn to_vec4(self) -> [f32; 4]
[src]
Converts a Point
to a OpenGL-style vec4
.
The result is padded to [x, y, 0, 1]
.
pub fn arr_from_vec2s(arr: &[[f32; 2]]) -> &[Point]
[src]
Reinterprets a slice of vec2
s as Point
s.
Does not allocate a new array, only changes the type of the pointer.
pub fn arr_to_vec2s(arr: &[Point]) -> &[[f32; 2]]
[src]
Reinterprets a slice of Point
s as vec2
s.
Does not allocate a new array, only changes the type of the pointer.
Trait Implementations
impl Clone for Point
[src]
fn clone(&self) -> Point
[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 Copy for Point
[src]
impl Default for Point
[src]
impl PartialEq for Point
[src]
fn eq(&self, __arg_0: &Point) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Point) -> bool
[src]
This method tests for !=
.
impl Debug for Point
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Transformation<Point> for Transform
[src]
fn transform(self, pt: Point) -> Point
[src]
Returns a transformed copy of an object. Read more
fn inverse_transform(self, pt: Point) -> Point
[src]
Transforms an object by the inverse of a transformation. Read more
fn transform_mut(self, operand: &mut T) where
T: Copy,
[src]
T: Copy,
Transforms an object, mutating it.
fn inverse_transform_checked(self, operand: T) -> Option<T>
[src]
Transforms an object by the inverse of a transformation. Read more
impl Add<Vector> for Point
[src]
type Output = Point
The resulting type after applying the +
operator.
fn add(self, other: Vector) -> Point
[src]
Performs the +
operation.
impl Add<Point> for Vector
[src]
type Output = Point
The resulting type after applying the +
operator.
fn add(self, other: Point) -> Point
[src]
Performs the +
operation.
impl Sub<Vector> for Point
[src]
type Output = Point
The resulting type after applying the -
operator.
fn sub(self, other: Vector) -> Point
[src]
Performs the -
operation.
impl Sub<Point> for Point
[src]
type Output = Vector
The resulting type after applying the -
operator.
fn sub(self, other: Point) -> Vector
[src]
Performs the -
operation.
impl AddAssign<Vector> for Point
[src]
fn add_assign(&mut self, other: Vector)
[src]
Performs the +=
operation.
impl SubAssign<Vector> for Point
[src]
fn sub_assign(&mut self, other: Vector)
[src]
Performs the -=
operation.