Inverse 2D rotation with negative parameters

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
atrus_ovis
Messages
99
Reaction score
0

Homework Statement


Say we have a 2D rigid body transform, with parameters [itex]p = [ p_1,p_2,p_3][/itex] 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 [itex](x_0, y_0)[/itex] as the center of rotation, you want to go through a list of points defining the figure, each being (x, y), translate to [itex](x- x_0, y- y_0)[/itex], then rotate through angle [itex]\theta[/itex], using, perhaps, the matrix
[tex]\begin{bmatrix}cos(\theta) & -sin(\theta) \\ sin(\theta) & cos(\theta)\end{bmatrix}[/tex]
then translate back, [itex](x+ x_0, y+ y_0)[/itex].
 
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.