PeachDrawing

PeachDrawing

Homography Struct

A projective map of the plane, a 3x3 matrix acting on the column vector (x, y, 1): the picture a 4x4 CSS transform (perspective included) makes of a flat element. Where an affine System.Numerics.Matrix3x2 keeps parallel lines parallel, this does not; the third row is what makes the difference (the divisor W).

public readonly struct Homography
Constructors  
Homography(double, double, double, double, double, double, double, double, double) A projective map of the plane, a 3x3 matrix acting on the column vector (x, y, 1): the picture a 4x4 CSS transform (perspective included) makes of a flat element. Where an affine System.Numerics.Matrix3x2 keeps parallel lines parallel, this does not; the third row is what makes the difference (the divisor W).
Properties  
Identity The map that leaves every point where it is.
IsAffine True when the third row does nothing, so straight lines stay parallel and a PDF cm can carry the map.
M11 The matrix entry in row 1, column 1.
M12 The matrix entry in row 1, column 2.
M13 The matrix entry in row 1, column 3.
M21 The matrix entry in row 2, column 1.
M22 The matrix entry in row 2, column 2.
M23 The matrix entry in row 2, column 3.
M31 The matrix entry in row 3, column 1.
M32 The matrix entry in row 3, column 2.
M33 The matrix entry in row 3, column 3.
Methods  
Apply(double, double) The image of a point, or null when it maps to infinity or behind the viewer (W not positive).
ApplyHomogeneous(double, double) The homogeneous image of (x, y): X, Y and the divisor W.
FromMatrix4(Matrix4x4) What a 4x4 (System.Numerics, row-vector convention) does to the plane z = 0: the points (x, y, 0, 1) drop their z and divide by the fourth coordinate.
Invert() The map that undoes this one, or null when this one is singular.
Negated() The same map scaled by -1, which is the same picture: used to make W positive where the element is.
ProjectRectangle(double, double, double, double, double) The image of the rectangle (left, top, right, bottom) as a polygon, cut off where it would reach the viewer’s plane (W at or below epsilon) before dividing, so the part of an element that passes behind the eye never projects to a smear across the page. Empty when none of it is in front.
Then(Homography, Homography) The map that does first and then second.
Translation(double, double) The map that moves every point by (dx, dy).
TryProjectRectangleBounds(double, double, double, double, double, double, double, double, double) The bounding box of ProjectRectangle(double, double, double, double, double)’s polygon, without building it: the same clip at W <= epsilon, on the stack. False when the projection is degenerate (fewer than three points, or wholly behind the viewer).