![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Hi,
I know, its a little bit off-topic but I've a little problem with
rotation.
The problem is for a game I need a rolling ball, so I made the matrix in
the first picture with the code below. As you can see in the blue
rectangles this runs good, when I rotate only one axis. But when both
axis must be rotated I don't get the result what I wan't. The second
picture show's how the green marked rectangle should look like. Or in an
other question how could I rotate both axis in the same time?
Can someone help me?
Thanke you,
Stefan
/*******************************************/
#include "colors.inc"
camera {
location <0, 0, 0>
look_at <0, 0, 1>
up <0, 1, 0>
right <4/3, 0, 0>
orthographic
}
background { color rgb 1 }
light_source { <120, 120, -105>, color White }
#declare Ball = union {
sphere { 0, 1
texture {
pigment { checker Red, White }
finish {
ambient .3
phong .3
phong_size 20
}
}
}
cylinder { y*1.2, y*-1.2, .1 pigment { Blue } finish { ambient .7 } }
cylinder { x*1.2, x*-1.2, .1 pigment { Green } finish { ambient .7}}
cylinder { z*1.2, z*-1.2, .1 pigment { Yellow } finish { ambient .7}}
}
#declare Group = union {
#local Count=0;
#while (Count<=35)
#local rx=int(Count/6);
#local ry=mod(Count, 6);
object {
Ball
//rotate -rx*30*y
//rotate -ry*30*x
rotate <-ry*30, -rx*30, 0>
translate <(rx-2.5)*2.5, (ry-2.5)*2.5, 0>
translate z*3
}
#local Count=Count+1;
#end
}
object {
Group
scale .0675
translate z*12
}
/*******************************************/
--
http://home.t-online.de/home/StefanWz/
Post a reply to this message
Attachments:
Download 'neu-5.jpg' (18 KB)
Download 'neu-6.jpg' (3 KB)
Preview of image 'neu-5.jpg'
![neu-5.jpg](/povray.binaries.images/attachment/%3C3A5EE735.FD1A75E4%40t-online.de%3E/neu-5.jpg?ttop=443840&toff=11350&preview=1)
Preview of image 'neu-6.jpg'
![neu-6.jpg](/povray.binaries.images/attachment/%3C3A5EE735.FD1A75E4%40t-online.de%3E/neu-6.jpg?ttop=443840&toff=11350&preview=1)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Weinzierl Stefan wrote:
> Hi,
>
> I know, its a little bit off-topic but I've a little problem with
> rotation.
>
> The problem is for a game I need a rolling ball, so I made the matrix in
> the first picture with the code below. As you can see in the blue
> rectangles this runs good, when I rotate only one axis. But when both
> axis must be rotated I don't get the result what I wan't. The second
> picture show's how the green marked rectangle should look like. Or in an
> other question how could I rotate both axis in the same time?
> object {
> Ball
> //rotate -rx*30*y
> //rotate -ry*30*x
> rotate <-ry*30, -rx*30, 0>
>
Rotation occurs in a set order, first around the x axis, then around the y,
and finally around the z axis, so your commented rotation statements are
different than the last one that is uncommented. To rotate around these axes
in a different order you must do it manually, as you have in the commented out
version.
It is posible to do it with matrix multiplication, so take a look at
http://enphilistor.users4.50megs.com/matrix.htm and use the matrix for
rotation around y and the matrix for rotation around x.
I beleive that you have to multiply rot(x) by rot(y) in that order, since
matrix multiplication is not commutative (which basically means the order is
important, swapping the order will give different results). You will also have
to take heed to John's warning and add the fourth column to both matrices
before you can multiply them.
The result of all of this is that from the coding point of view the easiest
way to acheive the rotation you want is to declare two rotation commands, and
the rest is academically interesting, but not necessary.
--
Josh English -- Lexiphanic Lethomaniac
eng### [at] spiritone com
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Weinzierl Stefan wrote:
> But when both
> axis must be rotated I don't get the result what I wan't.
I tried a similar thing, with rolling balls on a hilly golf course. I never
got it right after days of fiddling with the code. It is an extremely complex
problem and never got any advice that would fix it.
It was an animation like this:
http://members.nbci.com/_XMCM/gregjohn/animation.html#POV13 , only with
striped balls...
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <3A5EE735.FD1A75E4@t-online.de>, Weinzierl Stefan
<Ste### [at] t-online de> wrote:
> The problem is for a game I need a rolling ball, so I made the matrix in
> the first picture with the code below. As you can see in the blue
> rectangles this runs good, when I rotate only one axis. But when both
> axis must be rotated I don't get the result what I wan't. The second
> picture show's how the green marked rectangle should look like. Or in an
> other question how could I rotate both axis in the same time?
You may find the AxisRotate() macro helpful:
http://enphilistor.users4.50megs.com/macs.htm
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |