photonscore.transform2d
2-D affine transform (translation, rotation, scaling).
Builds a 2x3 transform matrix by chaining elementary operations and maps point coordinates through it. The matrix is stored column-major as 6 doubles [m00, m10, m01, m11, m02, m12] — the layout used by the LINCam driver position transform, so Transform2D.matrix can be sent over the wire as-is.
Transform2D
class Transform2D()Chainable 2-D affine transform (2x3 matrix).
Every call post-multiplies the current matrix, so the last transform in a chain is applied to the point first:
# Rotate by 10 degrees about the image center (2048, 2048)
t = Transform2D().move(2048, 2048).rotate(10).move(-2048, -2048)
x, y = t.map(x, y)Attributes
matrix: The 6 matrix elements, column-major[m00, m10, m01, m11, m02, m12].
scale
def scale(scale_x: float, scale_y: float | None = None)Scale by scale_x, scale_y (or uniformly when scale_y is omitted).
move
def move(dx: float, dy: float)Translate by (dx, dy).
rotate
def rotate(degree: float)Rotate counter-clockwise by degree degrees about the origin.
rotate_radians
def rotate_radians(alpha: float)Rotate counter-clockwise by alpha radians about the origin.
apply
def apply(*transform)Post-multiply with another transform; returns self.
Accepts either a single Transform2D or the 6 elements in row-major order (t00, t01, t02, t10, t11, t12).
map
def map(x, y)Map a point; returns (x, y).
x and y may be scalars or numpy arrays (mapped element-wise).