POV-Ray : Newsgroups : povray.advanced-users : [EMERGENCY] - Help with geometry... : [EMERGENCY] - Help with geometry... Server Time
29 Jul 2024 16:32:54 EDT (-0400)
  [EMERGENCY] - Help with geometry...  
From: Mike Williams
Date: 3 Dec 2001 16:00:50
Message: <jFAPOBACf+C8EwcF@econym.demon.co.uk>
Wasn't it Tony[B] who wrote:
>I need this for tomorrow, for a speech on computers. I want to have a model
>of a mouse for illustrative purposes. I've made a CSG of what it looks like
>from above and from the side, and intersected those to form the basic shape.
>I want to round the edges of the top part. I've got a while-loop that almost
>does it, but for some reason, things don't quite line up. Please help me.
>Thanks in advance!

I couldn't manage it using POV-Ray 3.1, but I've managed it using the
beta version of POV-Ray 3.5 and using MegaPOV.

I couldn't work out for myself where the little spheres should go, so I
used the new trace() facility to work out where the edges of the mouse
were located. I first sweep round the XZ plane looking for points where
it intersects the Small_Y_View. For each point I find I then trace
downwards from a point a long way vertically above it, to give me a
point on the top edge of the mouse. We know that the mouse is "Rounding"
thick, so the small sphere should be placed -y*0.5*Rounding down from
this top edge.

(Using sphere sweeps would be nicer than individual spheres, but since
it's an emergency I've not spent any time trying to code that.)

One extra tweak is that I changed the Small_Y_View from a union into a
merge because trace() kept finding interior surfaces of the object.
(Though I suppose I could have traced from the outside looking in, which
should work just as well).

The following code works in POV-Ray 3.5 (beta) and MegaPOV, but not in
POV-Ray 3.1 because it uses the new trace() facility.


#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>*3 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 =
merge // otherwise trace finds an internal face
{
 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}
 }
 object {X_View translate -y*Rounding}
}



#declare A = 0;
#while (A < 2*pi)
  // use trace to find the rim of the Y view
  #declare XZpos=trace(Small_Y_View, 0, <sin(A),0,cos(A)>);
  // trace from miles above downwards to find top edge
  #declare TopXYZ=trace(X_View, XZpos+y*5, -y);
  // sphere half "Rounding" down from there
  sphere {TopXYZ-y*Rounding*0.5 ,Rounding*0.5}
  #declare A=A+0.01;
#end


Post a reply to this message

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