POV-Ray : Newsgroups : povray.windows : Local Transformations Server Time
28 Jul 2024 16:27:47 EDT (-0400)
  Local Transformations (Message 12 to 21 of 21)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Ronald L  Parker
Subject: Re: Local Transformations
Date: 7 Jan 1999 21:26:01
Message: <36966a86.208572426@news.povray.org>
On Fri, 08 Jan 1999 02:02:37 GMT, par### [at] mailfwicom (Ronald L.
Parker) wrote:

>(a bunch of mumbo jumbo that only two people understood)

Whoops, I was wrong on that one.  Turns out you have to perform the
local transforms globally IN REVERSE ORDER.  So the hypothetical
(G1 G2 ... Gn)(L1 L2 ... Ln) is in fact done properly as
(LnG ... L2G L1G)(G1 G2 ... Gn).  I didn't see it because all the
examples have been symmetric.  Hope I didn't confuse you with my
mindless prattling.  The result is neater, though: you don't have to
worry about which ones are global and which local: just take all the
local ones, in reverse order, then all the global ones, in the
original order, and you're done.  Even if you started with 
G1 L1 G2 L2.


Post a reply to this message

From: Tony Vigil
Subject: Re: Local Transformations
Date: 7 Jan 1999 22:09:52
Message: <369578A1.CA3FC0FC@emc-inc.com>
Ronald,

Thank you very much for your in-depth lesson on tranformation sequences!  This is
basically what I thought I would have to do, but didn't want to.  It would be so much
less convoluted if we could just use local coordinate systems.

Sincerely,
Tony Vigil



P.S.  I already know who Thorsten Froelich is since I have read the POV manual - the
entire manual. :-)

Does he know who he is?


Post a reply to this message

From: Ken
Subject: Re: Local Transformations
Date: 7 Jan 1999 23:17:51
Message: <36958671.FAE49759@pacbell.net>
Ronald L. Parker wrote:

> 2. (Extra Credit) Find out who Thorsten Froelich is.  See if you can
>    determine why everyone's laughing about your telling him to reread
>    the documentation.

   Thorsten Froelich - a late 20th century monk creditited with the
abolishment of computer documantion burning. An interesting side
note is that he was an active member of an elite team that developed
advanced visualization software for the masses.

--
Ken Tyler

tyl### [at] pacbellnet


Post a reply to this message

From: Ron Parker
Subject: Re: Local Transformations
Date: 8 Jan 1999 09:53:08
Message: <36961bd4.0@news.povray.org>
On Thu, 07 Jan 1999 19:16:50 -0800, Tony Vigil <tvi### [at] emc-inccom> wrote:
>Ronald,
>
>Thank you very much for your in-depth lesson on tranformation sequences!  This is
>basically what I thought I would have to do, but didn't want to.  It would be so much
>less convoluted if we could just use local coordinate systems.

Perhaps.  One way to do so, I would think, is to have a set of macros to do 
global transformations that has the side-effect of storing the current 
transformation matrix into an array.  This will require a touch of linear 
algebra on the part of the macro writers, though.  Then, in addition, have 
another set of macros to do local transformations that first transforms by 
the inverse of the current matrix, then performs the appropriate local 
transformation, then transforms by the current matrix.  Finally, these macros 
would have to update the current matrix using multiplication from the left.  
(i.e. if the matrix is M and the new transform is T, the matrix should be 
updated to TM)  Note that the way POV's matrices are implemented they are not 
square.  I think one has to add a fourth column consisting of the transpose 
of (0 0 0 1) to make such multiplications work, and ignore that column when 
using the matrix to do transformations within POV, but I haven't verified 
that.

Of course, as you say, a patch to do this (or at least a patch to retrieve 
the current transformation matrix for an object into an array) would be quite 
useful.  The problem is, not all objects keep the current transformation 
matrix as such.  If you take an otherwise untransformed sphere, for example,
and scale isotropically, it just adjusts the center and radius appropriately
and leaves the current transformation matrix empty.  Rotating or translating
such a sphere only affects the center, again leaving the transformation 
matrix empty.  So unless you apply a matrix or an anisotropic scale to a 
sphere, it has no transformation matrix to retrieve.  Changing this might 
have a serious impact on rendering time.


Post a reply to this message

From: Ron Parker
Subject: Re: Local Transformations
Date: 8 Jan 1999 09:57:27
Message: <36961cd7.0@news.povray.org>
On Thu, 07 Jan 1999 19:16:50 -0800, Tony Vigil <tvi### [at] emc-inccom> wrote:
>Ronald,
>
>Thank you very much for your in-depth lesson on tranformation sequences!  This is
>basically what I thought I would have to do, but didn't want to.  It would be so much
>less convoluted if we could just use local coordinate systems.

One other thing I forgot in my previous followup to this message: make
sure you read my correction.  There's an error in my math that affects
most of what I said in that "in-depth lesson."


Post a reply to this message

From: Ron Parker
Subject: Re: Local Transformations
Date: 8 Jan 1999 10:32:17
Message: <36962501.0@news.povray.org>
On 8 Jan 1999 09:53:08 -0500, Ron Parker <par### [at] my-dejanewscom> wrote:
>On Thu, 07 Jan 1999 19:16:50 -0800, Tony Vigil <tvi### [at] emc-inccom> wrote:
>>Ronald,
>>
>>Thank you very much for your in-depth lesson on tranformation sequences!  This is
>>basically what I thought I would have to do, but didn't want to.  It would be so
much
>>less convoluted if we could just use local coordinate systems.
>
>Perhaps.  One way to do so, I would think, is to have a set of macros to do 
>global transformations that has the side-effect of storing the current 
>transformation matrix into an array. 
...
>Of course, as you say, a patch to do this (or at least a patch to retrieve 
>the current transformation matrix for an object into an array) would be quite 
>useful.

I just had a great idea that wouldn't require a patch and would be fairly 
painless, except that it doesn't work due to what appears to be a bug in 
POV-Ray. (It doesn't allow you to put transform identifiers in a transform
declaration unless they're the only thing in the declaration, contrary to
the documentation.)

#macro trans_rotate( trans, rot, islocal )
  #declare trans=transform {
     #if (islocal) rotate rot #end
     transform{trans}
     #if (!islocal) rotate rot #end
  }
#end

#macro trans_scale( trans, scl, islocal )
  #declare trans=transform {
     #if (islocal) scale scl #end
     transform{trans}
     #if (!islocal) scale scl #end
  }
#end

#macro trans_translate( trans, tr, islocal )
  #declare trans=transform {
     #if (islocal) translate tr #end
     transform{trans}
     #if (!islocal) translate tr #end
  }
#end

#declare My_trans=transform{ scale 1 } // identity matrix
trans_rotate( My_trans, 45*y, no ) // global rotate
trans_translate( My_trans, x, yes ) // local translate
...


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Local Transformations
Date: 8 Jan 1999 13:57:38
Message: <36965522.0@news.povray.org>
In article <369543CF.A44A2BFF@emc-inc.com> , Tony Vigil <tvi### [at] emc-inccom>  wrote:
>-45 degrees on the object's Y axis (no translations occuring), then translate 1 unit
>along the object's Z axis.  Now what???  The object should be at in it's original
>rotational state of <0,0,0> located at <0.71 , 0 , 0.29> - but it's not.

As this was not in your original post, how could I have known that would want to
several of these in a row.
Well, I don't have complete code for you, but I have something I used/wrote some time
ago that might give you a hint...

Do you know the programming language LOGO or any other language/graphic librbary
implementing a graphic turtle in 2D? Well, here is a simple version as POV-Ray
macros. I wrote it to get a nice handwriting simulation (the drawing turtle is the
ink or the pen) and therefore it is only 2D, but it should be possible to get some
useful macros that do the same in 3D. I added the Turtle_InsertTranslate() macro
which will move any object to the current turtle location.

Oh, and just one question: What exactly do you need the "local transformations" for?


    Thorsten




/* ***** Begin Turtle ***** */

#declare gTurtle = array[5]

/* Activate drawing to trace turtle */
#macro Turtle_DrawOn()
  #declare gTurtle[4] = 1;
#end

/* Deactivate drawing to trace turtle */
#macro Turtle_DrawOff()
  #declare gTurtle[4] = 0;
#end

/* Move to position, set default direction and deactivate drawing */
#macro Turtle_Move(tposx, tposy)
  #declare gTurtle[0] = tposx;
  #declare gTurtle[1] = tposy;
  #declare gTurtle[2] = 1;
  #declare gTurtle[3] = 0;
  #declare gTurtle[4] = 0;
#end

/* Turn the turtle left */
#macro Turtle_TurnLeft(tdeg)
  #local temp = <gTurtle[2], gTurtle[3], 0>;
  #local temp = vrotate(temp, <0, 0, -tdeg>);
  #declare gTurtle[2] = temp.x;
  #declare gTurtle[3] = temp.y;
  #if(gTurtle[4])
    sphere {
      <gTurtle[0], gTurtle[1], 0>, 0.5
      pigment { color red 1 }
      finish {
        ambient 0.2
        diffuse 0.7
        phong 1
        phong_size 80
        brilliance 2
      }
    }
  #end
#end

/* Turn the turtle right */
#macro Turtle_TurnRight(tdeg)
  #local temp = <gTurtle[2], gTurtle[3], 0>;
  #local temp = vrotate(temp, <0, 0, +tdeg>);
  #declare gTurtle[2] = temp.x;
  #declare gTurtle[3] = temp.y;
  #if(gTurtle[4])
    sphere {
      <gTurtle[0], gTurtle[1], 0>, 0.5
      pigment { color red 1 }
      finish {
        ambient 0.2
        diffuse 0.7
        phong 1
        phong_size 80
        brilliance 2
      }
    }
  #end
#end

/* Go forward the specified distance in units */
#macro Turtle_Forward(tlen)
  #local temp = <gTurtle[0], gTurtle[1], 0>;
  #declare gTurtle[0] = gTurtle[0] + (gTurtle[2] * tlen);
  #declare gTurtle[1] = gTurtle[1] + (gTurtle[3] * tlen);
  #if(gTurtle[4])
    cylinder {
      temp, <gTurtle[0], gTurtle[1], 0>, 0.5
      pigment { color red 1 }
      finish {
        ambient 0.2
        diffuse 0.7
        phong 1
        phong_size 80
        brilliance 2
      }
    }
  #end
#end

/* Insert a translate <x,y,0> of the current turtle
   position to change an objects location */
#macro Turtle_InsertTranslate()
  translate <gTurtle[0], gTurtle[1], 0>
#end

/* ***** End Turtle ***** */

camera {
  location  <0, 0, 20>
  right   <4/3, 0, 0>
  look_at   <0, 0, 2>
}

light_source { <0, 0, 50> color rgb 1 }

plane {
  z, 0
  pigment { color blue 1 }
  finish { ambient 0.15 diffuse 0.8 }
}


Turtle_Move(0,0)

Turtle_DrawOn()

Turtle_Forward(2)
Turtle_TurnLeft(60)
Turtle_Forward(2)
Turtle_TurnLeft(60)
Turtle_Forward(2)
Turtle_TurnLeft(60)

Turtle_Forward(1)

sphere {
  <0, 0, 0>, 0.7
  pigment { color green 1 }
  finish {
    ambient 0.2
    diffuse 0.7
    phong 1
    phong_size 80
    brilliance 2
  }
  Turtle_InsertTranslate()
}

Turtle_Forward(1)

Turtle_TurnLeft(60)
Turtle_Forward(2)
Turtle_TurnLeft(60)
Turtle_Forward(2)
Turtle_TurnLeft(60)


Post a reply to this message

From: Ron Parker
Subject: Re: Local Transformations
Date: 8 Jan 1999 15:21:30
Message: <369668ca.0@news.povray.org>
On 8 Jan 1999 10:32:17 -0500, I wrote:

>     transform{trans}

Whoops, another mistake. Even assuming the documentation were 
correct, this is not. The curly braces shouldn't be there.  
(It doesn't work right anyway, but I've been told the 3.1b 
update will fix it to work as documented.  See my bug report
in povray.bugreports if you want to know how to fix it yourself.)


Post a reply to this message

From: Tony Vigil
Subject: Re: Local Transformations
Date: 8 Jan 1999 16:50:26
Message: <36967F4C.D40D75C0@emc-inc.com>
THANK YOU THANK YOU THANK YOU!!!

You are awesome!!!




Thorsten Froehlich wrote:

> In article <369543CF.A44A2BFF@emc-inc.com> , Tony Vigil <tvi### [at] emc-inccom>  wrote:
> >-45 degrees on the object's Y axis (no translations occuring), then translate 1
unit
> >along the object's Z axis.  Now what???  The object should be at in it's original
> >rotational state of <0,0,0> located at <0.71 , 0 , 0.29> - but it's not.
>
> As this was not in your original post, how could I have known that would want to
> several of these in a row.
> Well, I don't have complete code for you, but I have something I used/wrote some
time
> ago that might give you a hint...
>
> Do you know the programming language LOGO or any other language/graphic librbary
> implementing a graphic turtle in 2D? Well, here is a simple version as POV-Ray
> macros. I wrote it to get a nice handwriting simulation (the drawing turtle is the
> ink or the pen) and therefore it is only 2D, but it should be possible to get some
> useful macros that do the same in 3D. I added the Turtle_InsertTranslate() macro
> which will move any object to the current turtle location.
>
> Oh, and just one question: What exactly do you need the "local transformations" for?
>
>     Thorsten
>
> /* ***** Begin Turtle ***** */
>
> #declare gTurtle = array[5]
>
> /* Activate drawing to trace turtle */
> #macro Turtle_DrawOn()
>   #declare gTurtle[4] = 1;
> #end
>
> /* Deactivate drawing to trace turtle */
> #macro Turtle_DrawOff()
>   #declare gTurtle[4] = 0;
> #end
>
> /* Move to position, set default direction and deactivate drawing */
> #macro Turtle_Move(tposx, tposy)
>   #declare gTurtle[0] = tposx;
>   #declare gTurtle[1] = tposy;
>   #declare gTurtle[2] = 1;
>   #declare gTurtle[3] = 0;
>   #declare gTurtle[4] = 0;
> #end
>
> /* Turn the turtle left */
> #macro Turtle_TurnLeft(tdeg)
>   #local temp = <gTurtle[2], gTurtle[3], 0>;
>   #local temp = vrotate(temp, <0, 0, -tdeg>);
>   #declare gTurtle[2] = temp.x;
>   #declare gTurtle[3] = temp.y;
>   #if(gTurtle[4])
>     sphere {
>       <gTurtle[0], gTurtle[1], 0>, 0.5
>       pigment { color red 1 }
>       finish {
>         ambient 0.2
>         diffuse 0.7
>         phong 1
>         phong_size 80
>         brilliance 2
>       }
>     }
>   #end
> #end
>
> /* Turn the turtle right */
> #macro Turtle_TurnRight(tdeg)
>   #local temp = <gTurtle[2], gTurtle[3], 0>;
>   #local temp = vrotate(temp, <0, 0, +tdeg>);
>   #declare gTurtle[2] = temp.x;
>   #declare gTurtle[3] = temp.y;
>   #if(gTurtle[4])
>     sphere {
>       <gTurtle[0], gTurtle[1], 0>, 0.5
>       pigment { color red 1 }
>       finish {
>         ambient 0.2
>         diffuse 0.7
>         phong 1
>         phong_size 80
>         brilliance 2
>       }
>     }
>   #end
> #end
>
> /* Go forward the specified distance in units */
> #macro Turtle_Forward(tlen)
>   #local temp = <gTurtle[0], gTurtle[1], 0>;
>   #declare gTurtle[0] = gTurtle[0] + (gTurtle[2] * tlen);
>   #declare gTurtle[1] = gTurtle[1] + (gTurtle[3] * tlen);
>   #if(gTurtle[4])
>     cylinder {
>       temp, <gTurtle[0], gTurtle[1], 0>, 0.5
>       pigment { color red 1 }
>       finish {
>         ambient 0.2
>         diffuse 0.7
>         phong 1
>         phong_size 80
>         brilliance 2
>       }
>     }
>   #end
> #end
>
> /* Insert a translate <x,y,0> of the current turtle
>    position to change an objects location */
> #macro Turtle_InsertTranslate()
>   translate <gTurtle[0], gTurtle[1], 0>
> #end
>
> /* ***** End Turtle ***** */
>
> camera {
>   location  <0, 0, 20>
>   right   <4/3, 0, 0>
>   look_at   <0, 0, 2>
> }
>
> light_source { <0, 0, 50> color rgb 1 }
>
> plane {
>   z, 0
>   pigment { color blue 1 }
>   finish { ambient 0.15 diffuse 0.8 }
> }
>
> Turtle_Move(0,0)
>
> Turtle_DrawOn()
>
> Turtle_Forward(2)
> Turtle_TurnLeft(60)
> Turtle_Forward(2)
> Turtle_TurnLeft(60)
> Turtle_Forward(2)
> Turtle_TurnLeft(60)
>
> Turtle_Forward(1)
>
> sphere {
>   <0, 0, 0>, 0.7
>   pigment { color green 1 }
>   finish {
>     ambient 0.2
>     diffuse 0.7
>     phong 1
>     phong_size 80
>     brilliance 2
>   }
>   Turtle_InsertTranslate()
> }
>
> Turtle_Forward(1)
>
> Turtle_TurnLeft(60)
> Turtle_Forward(2)
> Turtle_TurnLeft(60)
> Turtle_Forward(2)
> Turtle_TurnLeft(60)


Post a reply to this message

From: Tony Vigil
Subject: Re: Local Transformations
Date: 8 Jan 1999 16:57:39
Message: <36968103.40A127BB@emc-inc.com>
You too are awesome (as is Thorsten)!!!

My apologies to all for my lack of POV understanding & internet
etiquette!

Thanks for all of your help & patience.

Sincerely,

Tony Vigil


Ron Parker wrote:

> On 8 Jan 1999 10:32:17 -0500, I wrote:
>
> >     transform{trans}
>
> Whoops, another mistake. Even assuming the documentation were
> correct, this is not. The curly braces shouldn't be there.
> (It doesn't work right anyway, but I've been told the 3.1b
> update will fix it to work as documented.  See my bug report
> in povray.bugreports if you want to know how to fix it yourself.)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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