Skip to main content

TransBilinear

Struct TransBilinear 

Source
pub struct TransBilinear { /* private fields */ }
Expand description

Bilinear 2D transformation.

Solves for a 4x2 coefficient matrix that maps points between two quadrilaterals using bilinear interpolation:

x' = m[0][0] + m[1][0]*x*y + m[2][0]*x + m[3][0]*y
y' = m[0][1] + m[1][1]*x*y + m[2][1]*x + m[3][1]*y

Port of C++ trans_bilinear.

Implementations§

Source§

impl TransBilinear

Source

pub fn new() -> Self

Create an invalid (uninitialized) transform.

Source

pub fn new_quad_to_quad(src: &[f64; 8], dst: &[f64; 8]) -> Self

Create from arbitrary quadrilateral to quadrilateral mapping.

Source

pub fn new_rect_to_quad( x1: f64, y1: f64, x2: f64, y2: f64, quad: &[f64; 8], ) -> Self

Create a rectangle → quadrilateral mapping.

Source

pub fn new_quad_to_rect( quad: &[f64; 8], x1: f64, y1: f64, x2: f64, y2: f64, ) -> Self

Create a quadrilateral → rectangle mapping.

Source

pub fn quad_to_quad(&mut self, src: &[f64; 8], dst: &[f64; 8])

Set the transformation from two arbitrary quadrilaterals.

Solves a 4×2 system via Gaussian elimination.

Source

pub fn rect_to_quad( &mut self, x1: f64, y1: f64, x2: f64, y2: f64, quad: &[f64; 8], )

Set the direct transformation: rectangle → quadrilateral.

Source

pub fn quad_to_rect( &mut self, quad: &[f64; 8], x1: f64, y1: f64, x2: f64, y2: f64, )

Set the reverse transformation: quadrilateral → rectangle.

Source

pub fn is_valid(&self) -> bool

Check if the equations were solved successfully.

Source

pub fn transform(&self, x: &mut f64, y: &mut f64)

Transform a point (x, y).

Source

pub fn begin(&self, x: f64, y: f64, step: f64) -> IteratorX

Create an incremental iterator for scanline walking.

Trait Implementations§

Source§

impl Default for TransBilinear

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Transformer for TransBilinear

Source§

fn transform(&self, x: &mut f64, y: &mut f64)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.