POV-Ray : Newsgroups : povray.advanced-users : [EMERGENCY] - Help with geometry... : Re: [EMERGENCY] - Help with geometry... Server Time
29 Jul 2024 16:19:57 EDT (-0400)
  Re: [EMERGENCY] - Help with geometry...  
From: Rune
Date: 3 Dec 2001 16:39:09
Message: <3c0bf0fd@news.povray.org>
"Tony[B]" wrote:
> I need this for tomorrow, for a speech on computers.
> I want to have a model of a mouse for illustrative purposes.

I have three things to say:

1) I hope you get this in time.
2) I hope it is a *really* important emergency.
3) I hope nobody beat me to it.

...because it took me quite a while to do this!

> I've got a while-loop that almost does it, but for some
> reason, things don't quite line up. Please help me.

Couldn't understand it. Made my own version. Here you go:


// a computer mouse
// anthony bennett
// december 2, 2001

#default {pigment {rgb 1} finish {ambient 0 diffuse 1}}

#macro SIGN(NUM)
 #if (NUM>=0) 1 #else -1 #end
#end

global_settings {ambient_light 0 assumed_gamma 1}

camera {location <1,1,-1>*5 look_at 0}

light_source {<-1,2,-1>*15 1}

sky_sphere {pigment {rgb z}}

#declare X_View =
difference
{
 cylinder {-x*2,x*2,2}
 plane {y,0.5}
 plane {-z,0 translate z*1.0}
 plane {z,0 translate -z*1.5}
 translate <0,-0.5,0.25>
 scale <1.25,1,1/1.25*2.8>
}

#declare Y_View =
union
{
 difference
 {
  cylinder {-y,y*2,1 scale <1.25,1,2.55>}
  plane {z,0}
  translate  z*0.25
 }
 box {<-1.25,-1,-0.25>,<1.25,2,0.25>}
 difference
 {
  cylinder {-y,y*2,1 scale <1.25,1,2.55>}
  plane {-z,0}
  translate -z*0.25
 }
}

#declare Rounding = 0.1;

#declare Small_Y_View =
union
{
 difference
 {
  cylinder {-y*2,y*3,1 scale <1.25-Rounding,1,2.55-Rounding>}
  plane {z,0}
  translate  z*0.25
 }
 box {<-1.25+Rounding,-2,-0.25>,<1.25-Rounding,3,0.25>}
 difference
 {
  cylinder {-y*2,y*3,1 scale <1.25-Rounding,1,2.55-Rounding>}
  plane {-z,0}
  translate -z*0.25
 }
}

difference
{
 intersection
 {
  object {X_View}
  object {Small_Y_View scale <1,1,1.01>}
 }
 object {X_View translate -y*Rounding}
}

#declare Obj1 = Small_Y_View
#declare Obj2 = X_View
#include "math.inc"
union {
   #declare C = 0;
   #declare Samples = 1000;
   #while (C<Samples)
      #declare Norm = <0,0,0>;
      #declare Direction = vrotate(x,360*y*(C/Samples));
      #declare PosXZ = trace(Obj1, 100*Direction, -Direction, Norm)*<1,0,1>;
      #if (vlength(Norm)>0)
         #declare Norm = <0,0,0>;
         #declare PosY = trace(Obj2, 10*y+PosXZ, -y, Norm)*y;
         #if (vlength(Norm)>0)
            #declare Ang = VAngle(y,Norm);
            #declare Pos = (
               +PosXZ+PosY
               -Rounding*y
               -y*(cos(Ang)+(sin(Ang)*vlength(Norm*<1,0,1>))-1)*Rounding
            );
            sphere {Pos, Rounding}
         #end
      #end
      #declare C = C+1;
   #end
}


Post a reply to this message

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