POV-Ray : Newsgroups : povray.text.tutorials : Rotate around central axis Server Time
23 Nov 2024 03:17:36 EST (-0500)
  Rotate around central axis (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Philippe-H Cadet
Subject: Rotate around central axis
Date: 19 Dec 2000 02:03:29
Message: <3a3f0841$1@news.povray.org>
Hi. I have tried for months to find a way to rotate an object around it
central axis. How can I do that? I thought I could with the Matrix keyword
but if the object is not centered at the origin it does not work.

Some guy told me that I could use the vnormalize(...) function but the only
doc that I founded is

vnormalize(A) Normalize vector A. Returns a unit length vector that is the
same direction as A. Formula is vnormalize=A/vlength(A)

Can somebody help me rotate an object around it's own central axis please...
Philippe


Post a reply to this message

From: Warp
Subject: Re: Rotate around central axis
Date: 19 Dec 2000 04:00:10
Message: <3a3f2399@news.povray.org>
Philippe-H Cadet <del### [at] videotronca> wrote:
: Hi. I have tried for months to find a way to rotate an object around it
: central axis. How can I do that?

  Easy:

translate -ObjectCenter
rotate whatever
translate ObjectCenter

  You'll have to define ObjectCenter yourself.

-- 
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: Mick Hazelgrove
Subject: Re: Rotate around central axis
Date: 19 Dec 2000 14:17:50
Message: <3a3fb45e@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3a3f2399@news.povray.org...
> Philippe-H Cadet <del### [at] videotronca> wrote:
> : Hi. I have tried for months to find a way to rotate an object around it
> : central axis. How can I do that?
>
>   Easy:
>
> translate -ObjectCenter
> rotate whatever
> translate ObjectCenter
>

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.

Mick


Post a reply to this message

From: Philippe-H Cadet
Subject: Re: Rotate around central axis
Date: 19 Dec 2000 20:08:30
Message: <3a40068e$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3a3f2399@news.povray.org...
> Philippe-H Cadet <del### [at] videotronca> wrote:
> : Hi. I have tried for months to find a way to rotate an object around it
> : central axis. How can I do that?
>
>   Easy:
>
> translate -ObjectCenter
> rotate whatever
> translate ObjectCenter
>
>   You'll have to define ObjectCenter yourself.


Yes but ObjectCenter. How can I find that if it is not necessary a cube?
Note:
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.

Philippe


Post a reply to this message

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

Goto Latest 10 Messages Next 4 Messages >>>

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