Re: Graphic transforms

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I found out (the hard way) that my explanation was too simplified. I now am
aware it's a bit more complex than I previously thought.

For example. Translation. If you translate before you rotate then the
rotation is not about the desired rotation point. Further, one should scale
before rotating since scaling is on two different axis, and if rotation is
applied first then scaling the x-axis will be in the direction of the
ROTATED x-axis.

So. one must apply scale, then rotate, then translation. Before these
operations the object's rotation point must be translated to the origin (so
that rotation is, indeed, about this point), and after all is done
translated back the reverse vector that moved it to the origin.

Now, since translation must happen after both rotation and scaling, to
translate with respect to the original (screen) coordinate system the
translation must be adjusted accordingly. Thus, it must be rotated and
scaled as such:

adjusted_trans_x = ((trans_x * cos) - (trans_y * sin)) / scale_x
adjusted_trans_y = ((trans_y * cos) + (trans_x * sin)) / scale_y

Sooooo, one must 'bite the bullet' with respect to translation, which is
ironic since without rotation and scaling translation is typically the most
computationally simple, but with it the most computationally complex! : )

[==P==]


"Olaf Baeyens" <olaf.baeyens@xxxxxxxxxx> wrote in message
news:4360a973$0$15749$ba620e4c@xxxxxxxxxxxxxxxxx
>> This is the idea. One thinks of rotation as happening 'naturally' about a
>> certain point of an object......
>>...
>> Thus the full transform function is as follows:
>>
>> transform = T(-x-rotate_dx,-y-rotate_dy) S(scale_x,scale_y) R(r)
>> T(x+rotate_dx, y+rotate_dy) T(dx, Tdy)
>>
>> applied from left to right, with:
>>
>> T = translate
>> R = rotate
>> S = scale
>>
>> And there you have it! The trick is moving it to the wrod origin before
>> scaling and rotating to ease the computations, and to scale before
> rotating
>> since scaling can be performed on two axes.
>>
>> Is that what you were asking? : )
>>
> I believe you just killed the newsgroup with this quantum mechanics like
> explanation. :-)
> A lot of people here will need counseling here I guess. :-)
>
> But you are right in your explanation.
>
> But you forget that every object has another rotation called orientation.
> ;-)
> First is the rotation and translation regarding of your parent starting
> coordinate.
> Second the orientation rotation on it's own axis (assuming that you do not
> have an offset)
>
> I am happy that GDI+ has DirectX and OpenGL like transforming
> functionality.
> I missed that in GDI a lot.
>
> I noticed that in the Windows vista they have created a very simple
> DirectX
> engine usable in .NET, so I guess that 3D visualization will become much
> more easy to implement.
> But nevertheless, translation/rotation/scaling is confusing for any newbie
> trying it.
>
>


.



Relevant Pages