use of georegression.transform.InvertibleTransformSequence in project BoofCV by lessthanoptimal.
the class DistortSupport method transformRotate.
/**
* Creates a {@link boofcv.alg.distort.PixelTransformAffine_F32} from the dst image into the src image.
*
* @param x0 Center of rotation in input image coordinates.
* @param y0 Center of rotation in input image coordinates.
* @param x1 Center of rotation in output image coordinates.
* @param y1 Center of rotation in output image coordinates.
* @param angle Angle of rotation.
*/
public static PixelTransformAffine_F32 transformRotate(float x0, float y0, float x1, float y1, float angle) {
// make the coordinate system's origin the image center
Se2_F32 imageToCenter = new Se2_F32(-x0, -y0, 0);
Se2_F32 rotate = new Se2_F32(0, 0, angle);
Se2_F32 centerToImage = new Se2_F32(x1, y1, 0);
InvertibleTransformSequence sequence = new InvertibleTransformSequence();
sequence.addTransform(true, imageToCenter);
sequence.addTransform(true, rotate);
sequence.addTransform(true, centerToImage);
Se2_F32 total = new Se2_F32();
sequence.computeTransform(total);
Se2_F32 inv = total.invert(null);
Affine2D_F32 affine = ConvertTransform_F32.convert(inv, (Affine2D_F32) null);
PixelTransformAffine_F32 distort = new PixelTransformAffine_F32();
distort.set(affine);
return distort;
}
Aggregations