Fastest way of doing transformations (Move, Rotate, Scale)
I was looking at this vector drawing application called Creative Docs .Net . I noticed that I can have hundreds of shapes and moving, rotating and scaling do not lag at all. Given that al开发者_开发技巧l verticies must be modified, how do applications generally do these transformations as quickly as possible?
Thanks
One typical way to do it is to apply a 3x3 (or 3x2, or 2x3) affine transformation matrix to the coordinates, which can describe things like position, rotation, scale and shear.
If you use OpenGL or Direct3D you can use the graphics hardware to do the actual transformations for you.
If you do it in software, rasteration is probably going to be the bottleneck, not transforming the vertices.
In addition to using matrices to mimic affine transformation (linear transformations with translation), you might be interested in the use of Quaternions to perform those operations in R3.
Typically this is done via transformation matrices. This allows the individual points to be transformed fairly quickly, and is the most common technique used by most 2D (and 3D) vector based drawing.
That application, in particular, is built on top of Anti-Grain Geometry - a fairly high-performance open source 2D rendering engine. It provides many of the "primitives" which could be used for this type of application.
精彩评论