POV-Ray : Newsgroups : povray.windows : Local Transformations : Re: Local Transformations Server Time
28 Jul 2024 18:13:48 EDT (-0400)
  Re: Local Transformations  
From: Tony Vigil
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

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