POV-Ray : Newsgroups : povray.binaries.images : Problems with rotation... Server Time
19 Aug 2024 06:22:45 EDT (-0400)
  Problems with rotation... (Message 1 to 4 of 4)  
From: Weinzierl Stefan
Subject: Problems with rotation...
Date: 12 Jan 2001 06:39:54
Message: <3A5EE735.FD1A75E4@t-online.de>
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

Preview of image 'neu-6.jpg'
neu-6.jpg


 

From: Josh English
Subject: Re: Problems with rotation...
Date: 12 Jan 2001 07:21:15
Message: <3A5EF729.E37BC7FD@spiritone.com>
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] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Problems with rotation...
Date: 12 Jan 2001 07:50:34
Message: <3A5EFC39.9840D371@my-dejanews.com>
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

From: Chris Huff
Subject: Re: Problems with rotation...
Date: 12 Jan 2001 17:13:59
Message: <chrishuff-A4311F.17154012012001@news.povray.org>
In article <3A5EE735.FD1A75E4@t-online.de>, Weinzierl Stefan 
<Ste### [at] t-onlinede> 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] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.