How to build a rotation plugin?

How to build a rotation plugin?

Post by Lo van den Ber » Thu, 24 Sep 1998 04:00:00



Hi,

as an exercise in learning how to write a plugin for the Gimp I am
writing a rotation plugin using GTK+. In this process I encounter some
problems: I have no knowledge about graphics algorithms so I'm building
a brute-force algorithm.

Question: Do you know of some good graphics-algorithm books focussing on
2D algorithms?

Then the algorithm:

- get a rectangular area containing image data.
- use upperleft corner as origin.
- get the user defined angle.
    example: angle is 30 degrees.
- compute the size of the new image using simple Pythagoras.
    new width becomes  ( cos(angle) * oldwidth ) + ( sin(angle) *
oldheight ).
- compute the coordinates of the rotated image in the new grid.

     0    1    2    3     -> x
    0----------------------------------------------
     |    |   /|\   |    |    |    |    |    |    |
     |    |  / |   /\    |    |    |    |    |    |
    1|    | /  |  / |  /\|    |

    |
    v
    y

    as can be seen in this very primitive view the coordinates will be
floats. The origin of the old image is translate to (2,0). The following
coordinate is translated to something like ( 2.7, 0.5). The coordinates
represent the corners of the pixels.

- compute the surfaces of the several pixels which are inside a new
pixel. As can be seen in the view above, the pixel starting at (2,0)
contains at least two old pixels and a piece, which was not part of the
old image.

Question: How do I compute how much the percentages of how much of the
new pixel is covered by the parts of the old pixels?

- For each new pixel compute the new color using the computed
percentages.
- paint the new image.

Question: Am I being totally stupid in using this ad-hoc approach? Are
there smarter approaches?

Lo van den Berg

 
 
 

1. How do I build a rotation matrix

Hello there,

I have got the following problem:

Given two source vectors V1 and V2 with angle alpha between them, and
two target vectors V3 and V4 with the same angle.
V is defined in a 3D-space.

How do I build a rotation matrix which maps V1 to V3 and V2 to V4.
All vectors have the same origin.

Can anyone give me the algorithm (in C) or give any pointers to
literature where I can find this kind of problems?

Thanks,

Frank Hollander
University of Nijmegen
The Netherlands

2. Shadow using Stencil

3. Building rotation matrix from direction vector

4. Can someone help me ?

5. Building rotation matrix

6. Why is my first layer...

7. Building a transformation (rotation) matrix

8. Two Dimension Fourier Transform

9. ParentCamera plugin no longer works - LW Build 255

10. Error while using book building plugin

11. Problems with Build-Booklet-Plugin

12. Build Booklet plugin question

13. Build Booklet Plugin