POV-Ray : Newsgroups : povray.text.tutorials : Rotate around central axis Server Time
20 Apr 2024 04:14:33 EDT (-0400)
  Rotate around central axis (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: Philippe-H Cadet
Subject: Re: Rotate around central axis
Date: 19 Dec 2000 20:35:46
Message: <3a400cf2$1@news.povray.org>
> Or if you are simple minded like me
>
> create or translate the object at <0,0,0>
> rotate it
> translate it wherever you need it to go.




Thanks. But maybe there is something I'm missing here.
I tried you solution. When I do create an object at  a n y  place in the 3D
world and then translate it to <0,0,0>, the object should remain at the same
place. It will not be translated to the global center. For sure, if I do a
rotate it will still be rotated  around  the global axis.

Ex:
#declare testbox = object
{
        box
        {
                <-.5+2, -.5+2, -2+2> < .5+2,  .5+2,  2+2>
                pigment { red 0.9 green 0.7 blue 0.7 }
                translate <0,0,0>
        }
}

object{testbox}

By the way, I tried creating objects at <0,0,0> it seems that it is not
precise for the further  transformations. It is really hard to determine the
exact middle of a union object from my point of view.
Hum. I'm not done yet with that problem.


Post a reply to this message

From: Warp
Subject: Re: Rotate around central axis
Date: 20 Dec 2000 06:50:13
Message: <3a409cf5@news.povray.org>
Philippe-H Cadet <del### [at] videotronca> wrote:
:         box
:         {
                  ...
:                 translate <0,0,0>
:         }

  A translate <0,0,0> does nothing. Absolutely nothing.

  The 'translate' command does NOT mean "translate to".
  It means "translate by". Or "add this vector to the current location".

  That's why you should decide what is the center of the object and then
do something like this (supposing that you decide that the center of the
object is located at <1,2,3>):

#declare ObjectCenter = <1,2,3>;

object
{ MyObject
  translate -ObjectCenter
  rotate whatever
  translate ObjectCenter
}

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Warp
Subject: Re: Rotate around central axis
Date: 20 Dec 2000 07:00:13
Message: <3a409f4d@news.povray.org>
Philippe-H Cadet <del### [at] videotronca> wrote:
: Yes but ObjectCenter. How can I find that if it is not necessary a cube?

  How could povray find it if even you can't find it?
  The center of the object is where you decide it is.

  And no, povray can't calculate a center for the object automatically.
  Why? For many reasons. One of them is that the center of an object may
not be unambiguous.
  Just think about a triangle. What is the center of the triangle? Is it
the average of the vertex points? Is it the intersection of the lines tangent
to the sides of the triangle, going through the center of the side? Is it
the intersection of the middle-angles of the vertex angles? Something else?
  Another reason is that it's not even possible to do it with many objects.
  How do you calculate the center of a julia object? An isosurface? A poly?
What is the center of a plane?

: I thought about translating the global x,y,z axis on the center of the
: object and then after, rotate then translate back the global axis where it
: was before. But the aigain there is no functions that I know to translate
: the global axis.

  I said how to do it, but you didn't believe me:

object
{ MyObject
  translate -ObjectCenter
  rotate whatever
  translate ObjectCenter
}

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Tom Melly
Subject: Re: Rotate around central axis
Date: 20 Dec 2000 10:57:04
Message: <3a40d6d0$1@news.povray.org>
"Philippe-H Cadet" <del### [at] videotronca> wrote in message
news:3a3f0841$1@news.povray.org...

Hi Philippe,

As you may have gathered (or not), you have one or two very common
misconceptions to abandon.

Warp's info is the most accurate, but possibly not the most comprehensible
to a novice.

The best way, IMHO, to avoid muddles is to always create objects with a
point that rests at <0,0,0>. It doesn't matter which point (e.g. the center
of a sphere or its base), just as long as you know which point.

Secondly, always scale, then rotate and finally translate (there are many
exceptions to this, but you will generally recognise them as exceptions).

I call this my door rule: 1st you scale your hand to the door-knob, then you
rotate the knob, finally you push or pull (translate) the door.

To see why, try this scene where scale and translate are swapped on
otherwise similiar spheres:

//  start scene
camera{location <0,0,-50> look_at 0}
light_source{<0,0,0> color rgb 1 translate <10, 10, -30>}

sphere{<0,1,0>, 1 scale 10 translate <5,0,0> pigment{rgb<1,0,0>}} // base of
sphere at x = 0, so when scaled it stayed at 0 as 10*0 is still 0
sphere{<0,1,0>, 1 translate <-5,0,0> scale 10 pigment{rgb<0,1,0>}} // base
of the sphere was at x = -5, so when scaled it moved to x=-50 (10*-5)

// end scene

The point to note is that scaling and rotation take place relative to
<0,0,0>. Translation takes place relative to the object. The object itself
has no defined center, nor any special relationship to <0,0,0>. Also, as
Warp said, translation means move all points of the object by this amount,
not to a particular co-ordinate. Therefore "translate <0,0,0>" means "do not
move the object", not "move it to <0,0,0>".

Hope this helps.


Post a reply to this message

From: Philippe-H Cadet
Subject: Re: Rotate around central axis
Date: 21 Dec 2000 01:44:14
Message: <3a41a6be$1@news.povray.org>
>   A translate <0,0,0> does nothing. Absolutely nothing.
>   The 'translate' command does NOT mean "translate to".
>   It means "translate by". Or "add this vector to the current location".
>   That's why you should decide what is the center of the object and then
> do something like this (supposing that you decide that the center of the
> object is located at <1,2,3>):
>
> #declare ObjectCenter= <1,2,3>;
>
> object
> { MyObject
>   translate -ObjectCenter
>   rotate whatever
>   translate ObjectCenter
> }

Ok. I think got it now. For this I assume that when creating the
object, I have to be careful while writing the dimentions. I mean
that in order to perform a rotation on the y axis of the object,
ObjectCenter
has to reflect this intention by it's x or z coordinate.

Because if I have to move object it to the position <0,0,0> (with the
ObjectCenter
vector) and have a perfect rotation on it self,  after a lot of sucessive
translate - rotate - translate.... there can be some errors due to
the fact that the object is not properly centered with the normal
of the rotation I want it to rotate.

Philippe


Post a reply to this message

From: Philippe-H Cadet
Subject: Re: Rotate around central axis
Date: 21 Dec 2000 02:07:41
Message: <3a41ac3d@news.povray.org>
>   Just think about a triangle. What is the center of the triangle? Is it
> the average of the vertex points? Is it the intersection of the lines
tangent
> to the sides of the triangle, going through the center of the side? Is it
> the intersection of the middle-angles of the vertex angles? Something
else?
>   Another reason is that it's not even possible to do it with many
objects.
>   How do you calculate the center of a julia object? An isosurface? A
poly?
> What is the center of a plane?

Yes, you are right!
I did not looked at this perspective. I was thinking it was
possible to know the 2d center by the the average of the vertex points or by
calculating
the area for a face and the apply the 2d rotation by the normal centered to
the whole object.
As I can see Povray is not vertex based, anyways I goin to try avoid this
metal illusion
that a shape or 3d object can have a middle.

Philippe


Post a reply to this message

From: Tom Melly
Subject: Re: Rotate around central axis
Date: 21 Dec 2000 06:03:08
Message: <3a41e36c@news.povray.org>
"Philippe-H Cadet" <del### [at] videotronca> wrote in message
news:3a41ac3d@news.povray.org...

> As I can see Povray is not vertex based, anyways I goin to try avoid this
> metal illusion
> that a shape or 3d object can have a middle.
>

It's a very common beginners misconception. I suspect because beginners
start with the simple shapes such as sphere etc. which can easily behave as
though they do have a centre (as well as having their position defined with
just one set of co-ordinates).

For me, it wasn't until I started working with blobs that I began to
understand what was going on.


Post a reply to this message

From: Warp
Subject: Re: Rotate around central axis
Date: 21 Dec 2000 07:06:00
Message: <3a41f228@news.povray.org>
Tom Melly <tom### [at] tomandlucouk> wrote:
: It's a very common beginners misconception. I suspect because beginners
: start with the simple shapes such as sphere etc.

  This is probable the most common reason.
  It's easy to believe that a beginner (and even a not so beginner) could
think something like this:

  Ok, I make a
sphere
{ <1,2,3>, 1
  texture { Wood }
}
  This means that the center of the sphere is at <1,2,3> and its radius is 1.
  Now I'll rotate it around its center so that I get a rotating ball:

sphere
{ <1,2,3>, 1
  texture { Wood }
  rotate <0,45,0>
}

  Oops! What happened? Why it didn't rotate around its center but it moved
to a totally different place?

  The user has confused the center coordinate of the sphere with the
rotation axis center. It's quite natural to think that the center of the
sphere is the center of the rotation axis.
  However, when the user makes something like this, he will be quite
confused:

union
{ sphere { <-.5,0,0>, 1 }
  sphere { <1,0,.5>, 1 }
  texture { Wood }
  rotate <0,45,0>
}

  "Uh... What is the center of this object now? Is it <-.5,0,0>? Is it
<1,0,.5>? Is it somewhere in the middle? What does the rotation actually
do to this object?"

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Warp
Subject: Re: Rotate around central axis
Date: 21 Dec 2000 07:11:48
Message: <3a41f384@news.povray.org>
Tom Melly <tom### [at] tomandlucouk> wrote:
: Warp's info is the most accurate, but possibly not the most comprehensible
: to a novice.

  What?! What?! That was just outrageous!

  ;)

: The best way, IMHO, to avoid muddles is to always create objects with a
: point that rests at <0,0,0>. It doesn't matter which point (e.g. the center
: of a sphere or its base), just as long as you know which point.

  It's good to know how to rotate around a certain point, which may not
necessarily be <0,0,0>.
  For example, it may be possible that the user wants to rotate the object
first around one point and then around another different point.

: Secondly, always scale, then rotate and finally translate (there are many
: exceptions to this, but you will generally recognise them as exceptions).

  It should be noted that it's not a mandatory rule to have one scale, one
rotate and one translate per object and in that order.
  It's perfectly possible to, for example, first scale, then rotate, than
scale again, then translate and then rotate again. There's practically no
limit in the amount and combinations of transformations.
  Of course it requires experience to handle a complex combination of
transformations.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Tom Melly
Subject: Re: Rotate around central axis
Date: 21 Dec 2000 07:46:14
Message: <3a41fb96@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3a41f228@news.povray.org...
>
> union
> { sphere { <-.5,0,0>, 1 }
>   sphere { <1,0,.5>, 1 }
>   texture { Wood }
>   rotate <0,45,0>
> }
>
>   "Uh... What is the center of this object now? Is it <-.5,0,0>? Is it
> <1,0,.5>? Is it somewhere in the middle? What does the rotation actually
> do to this object?"

Exactly - it was running into this kind of issue with blobs that I realised
a) pov didn't work how I thought it did and b) the notion of objects having
a "center" was wrong.


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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