optris::sdk::Placement
Where one camera's frame sits on the canvas.
The truth is matrix, an affine from frame coordinates into canvas coordinates. Everything else on this struct composes into it or decomposes out of it, exactly; the friendly form is MakeTrs(origin, {zoom, zoom}, radians) and nothing more, so Zoom() and RotationDeg() read straight back off the matrix.
Set matrix directly for anything the friendly form cannot say: a shear, an alignment solved by a calibration step, a homography once Matrix3's bottom row starts being used. Measurement only ever asks for the inverse, so it does not care which route produced it.
Public attributes
matrix
Matrix3 matrix = kIdentity3
Frame space -> canvas space.
Public static functions
Centred
static auto Centred(uint32_t frame_width, uint32_t frame_height, Vec2 at, float zoom=1.0F, float rotation_deg=0.0F) -> Placement
A placement that puts the centre of a frame_width x frame_height frame at at in canvas coordinates, rotated and zoomed about that centre. This is what a user means by "rotate
the image": the picture turns where it sits rather than swinging around the canvas origin.
zoom is in canvas-space units, not pixels: 1.0 makes the frame exactly as wide as the canvas, 2.0 twice as wide. It is deliberately not a pixel ratio, which would change meaning the moment the canvas was resized. For a one-pixel-per-pixel placement pass float(frame_width) / canvas_width.
Public functions
SetRotationDeg
void SetRotationDeg(float degrees, uint32_t frame_width, uint32_t frame_height)
Rotate about the frame's own centre, leaving that centre where it is on the canvas. The frame size is a parameter because the matrix alone cannot say where the frame's centre is.
SetZoom
void SetZoom(float zoom, uint32_t frame_width, uint32_t frame_height)
Zoom about the frame's own centre, leaving that centre where it is on the canvas.
SetFrameCentre
void SetFrameCentre(Vec2 at, uint32_t frame_width, uint32_t frame_height)
Move the frame's centre to at, in canvas coordinates.
Pan
void Pan(Vec2 delta)
Slide the frame by delta canvas units. No frame size needed; a translation is a translation.
Zoom
auto Zoom() const -> float
RotationDeg
auto RotationDeg() const -> float
FrameCentre
auto FrameCentre(uint32_t frame_width, uint32_t frame_height) const -> Vec2
HasShear
auto HasShear() const -> bool
True when the matrix carries a shear the accessors above cannot represent: a directly-set matrix, or a non-uniform scale.
IsIdentity
auto IsIdentity() const -> bool
True when this places the frame unchanged: the canvas is the frame and nothing has moved.
Inverse
auto Inverse() const -> std::optional< Matrix3 >
Canvas space -> frame space. std::nullopt when the placement is singular (zoom 0, or a matrix collapsed to a line) because then no canvas point names a frame point and there is nothing honest to measure.