libcamera: transform: Invert operator*() operands

The current definition of operator*(Transform t1, Transform t0) follows
the function composition notion, where t0 is applied first then t1 is
applied last.

In order to introduce operator*(Orientation, Transform) where a
Transform is applied on top of an Orientation, invert the operand order
of operator*(Transform, Transform) so that usage of operator* with both
Orientation and Transform can be made associative.

For example:

Orientation o;
Transform t = t1 * t2
Orientation o1 = o * t
	       = o * (t1 * t2) = (o * t1) * t2 = o * t1 * t2

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi
2023-10-19 16:01:27 +02:00
committed by Laurent Pinchart
parent 250577878b
commit b54c935dd7
2 changed files with 13 additions and 13 deletions

View File

@@ -1136,7 +1136,7 @@ Transform CameraSensor::validateTransform(Transform *transform) const
* Combine the requested transform to compensate the sensor mounting
* rotation.
*/
Transform combined = *transform * rotationTransform_;
Transform combined = rotationTransform_ * *transform;
/*
* We combine the platform and user transform, but must "adjust away"
@@ -1165,7 +1165,7 @@ Transform CameraSensor::validateTransform(Transform *transform) const
* If the sensor can do no transforms, then combined must be
* changed to the identity. The only user transform that gives
* rise to this is the inverse of the rotation. (Recall that
* combined = transform * rotationTransform.)
* combined = rotationTransform * transform.)
*/
*transform = -rotationTransform_;
combined = Transform::Identity;