pub struct HomographyMatrix {
pub m: [[f64; 3]; 3],
}Expand description
A 3×3 homography (perspective transform) matrix stored in row-major order.
The matrix maps homogeneous source coordinates [x, y, 1] to destination
coordinates:
[x', y', w'] = H * [x, y, 1]
dst = (x'/w', y'/w')Fields§
§m: [[f64; 3]; 3]Row-major 3×3 matrix coefficients.
Implementations§
Source§impl HomographyMatrix
impl HomographyMatrix
Sourcepub fn translation(tx: f64, ty: f64) -> Self
pub fn translation(tx: f64, ty: f64) -> Self
Create a 2D translation matrix.
Sourcepub fn rotation(angle_rad: f64) -> Self
pub fn rotation(angle_rad: f64) -> Self
Create a counter-clockwise rotation matrix around the origin.
Sourcepub fn apply(&self, x: f64, y: f64) -> Option<(f64, f64)>
pub fn apply(&self, x: f64, y: f64) -> Option<(f64, f64)>
Apply the homography to a point (x, y).
Returns None if the projective w coordinate is near zero (degenerate).
Trait Implementations§
Source§impl Clone for HomographyMatrix
impl Clone for HomographyMatrix
Source§fn clone(&self) -> HomographyMatrix
fn clone(&self) -> HomographyMatrix
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for HomographyMatrix
Source§impl Debug for HomographyMatrix
impl Debug for HomographyMatrix
Source§impl PartialEq for HomographyMatrix
impl PartialEq for HomographyMatrix
Source§fn eq(&self, other: &HomographyMatrix) -> bool
fn eq(&self, other: &HomographyMatrix) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for HomographyMatrix
Auto Trait Implementations§
impl Freeze for HomographyMatrix
impl RefUnwindSafe for HomographyMatrix
impl Send for HomographyMatrix
impl Sync for HomographyMatrix
impl Unpin for HomographyMatrix
impl UnsafeUnpin for HomographyMatrix
impl UnwindSafe for HomographyMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more