Inverse 2D rotation with negative parameters

AI Thread Summary
To achieve an inverse transformation of a 2D rigid body transform with negative parameters, the challenge lies in accurately rotating around the current center of the image after transformations have been applied. The initial transformation alters the image center, complicating the application of inverse parameters directly. A proposed solution involves creating two routines: one for the forward transformation and another for the backward transformation, which first restores the image center before applying the inverse rotation and translations. This dual routine approach, while effective, is seen as undesirable due to the complexity it introduces. The discussion emphasizes the need for a method that allows for a single routine to handle both transformations seamlessly.
atrus_ovis
Messages
99
Reaction score
0

Homework Statement


Say we have a 2D rigid body transform, with parameters p = [ p_1,p_2,p_3] for rotation, x translation and y translation respectively.
I'm using the transform to .. transform an image.

Is there a way to have:
For a point x , y : x',y' = transform(x,y,p) <=> x,y = transform(x',y',-p) , meaning trasforming the transformed point with negative parameters of the initial transformation, gives us the initial point.
Expanding to the image, , i'd want for an image I:
I' = transform(I,p) <=> I = transform(I',-p)

This works simply for transforms that include only translations, but not for rotations.

The rotation is done by rotating the points by the center of ther image.
So by using a 2D rotation matrix with homogenous coordinates to include translation , i have to ,prior to rotation , translate the image by -cx,-cy where cx,cy are the coordinates of the image center , rotate , and then applying the translation.
By this way though , i'd have to know all prior transformations done to the image to know the (now changed) "location" of the image center.

So in short:
I have an image I', transformed by coordinates p.I want a transformation method to yield I when transforming I' with parameters -p.

Any ideas for this to work? Is it even possible?
 
Physics news on Phys.org
I take it that p2 and p3 are the x and y translations but what is p1? The angle through which the figure rotated? But rotated about what point? The center? One corner?

Yes, translate the center of rotation to the origin, perform the rotation, then translate back again.

That is, taking (x_0, y_0) as the center of rotation, you want to go through a list of points defining the figure, each being (x, y), translate to (x- x_0, y- y_0), then rotate through angle \theta, using, perhaps, the matrix
\begin{bmatrix}cos(\theta) &amp; -sin(\theta) \\ sin(\theta) &amp; cos(\theta)\end{bmatrix}
then translate back, (x+ x_0, y+ y_0).
 
As i said, i rotate around the image center.
p1 is the rotation angle,p2 and p3 the x ,y translations respectively.

I am doing what you describe , but the problem is the following:
Say i have an image I', its center located at cx,cy, and it's transformed by p1,p2,p3.
(These parameters are unknown to me).
But by that transformation, the new image center ( that corresponds visually and logically to the initial image center) is now at cx + p2 , cy + p3.

If i use the same routine to apply a new transformation , i will rotate around cx,cy which is not the current image centre, but the initial one, so i won't get the initial image with parameters -p1 -p2 -p3.

A possible solution, is that i could have 2 routines, one for the "forward" transform that behaves the way you described, and one for the "backwards" transform, that firstly translates by -p2 -p3, and then applies the transformation. In that way, the image center will firstly get restored to its proper position and the rotation will be done "correctly".

But having two routines is undesirable.
 
I tried to combine those 2 formulas but it didn't work. I tried using another case where there are 2 red balls and 2 blue balls only so when combining the formula I got ##\frac{(4-1)!}{2!2!}=\frac{3}{2}## which does not make sense. Is there any formula to calculate cyclic permutation of identical objects or I have to do it by listing all the possibilities? Thanks
Back
Top