Syndicate

You are here

3-D Rotation Script

This script will rotate an existing image about the X, Y and Z axes. It will also include a magnification factor so you can scale your image while rotating.

The inputs are the angles to rotate the image around the X, Y, and Z axes. Some values (usually high X and Y values) will result in a very distorted picture, regardless of what other inputs you have. If you get one of those, just undo and try again. That's just the way math works, folks!

The "Camera Position" controls several things, including how distorted the image will be. The default value gives good results most of the time. Very large values will tend to somewhat smooth out larger rotation angles.

The magnification factor will scale up the area of the image. A 640x480 image with a magnification factor of 1.5x, would have a rotated area of 640x480x1.5 pixels. The canvas itself will be larger than that, as there will be transparent areas around the rotated base image. As you would expect, large values for the magnification factor will result in very large images that will take up lots of memory.

In addition to the script, I've attached a picture of a rendered grid, and the picture of that grid rotated with the default values of the script. When installed, the script will appear in the Filters/SambrookJM menu, but that can be changed by editing the last line of the script to put it wherever you want in your menu hierarchy.

[Edit] I've added a "(Zero will give you an error. Please do not use that value.)" message on the script window for the camera location, and changed the default camera value to 9.9 to make it more difficult to get to 0 via the arrows.

In all seriousness, the script calculates the new location to "see" the rotated image (chosen by your magnification factor) by dividing by the area after the first run through of the script. If your camera position is zero, then the area will be zero, which will result in a divide by zero error.

I should have put a warning about that in the script window. Sorry, but there's not much else that can be done about that.

I tried with gimp 2.6.11 under windows XP and I had the error.
This is easily corrected, in the Brick Wall script, by changing the lowest value for "Color Variations ". There just has to replace 0 by 1.
It is more difficult for "3-D Rotation Script". Why not put "0 = random" or an option like that?
[edit] you were quicker than me to post

I wish Windows were that efficient, but alas, it's just my sloppy coding. :-(

When did you get the divide by zero error in this script? If it's when you set the camera location to zero, then yes, you will get a division by zero error. (See the above comment.)

I didn't catch the comment in the Brick Wall thread about the color variation being set to zero giving an error...sorry about that. That error was caused something different; GIMP trying to run the command (rand 0) because of the way the variables were calculated. It now does (rand 1) instead, which should result in zero. I fixed that one, and I'll repost the script with the fix. Good catch on that one.