POV-Ray : Newsgroups : povray.advanced-users : [EMERGENCY] - Help with geometry... Server Time
1 Nov 2024 19:16:12 EDT (-0400)
  [EMERGENCY] - Help with geometry... (Message 1 to 7 of 7)  
From: Tony[B]
Subject: [EMERGENCY] - Help with geometry...
Date: 2 Dec 2001 23:41:04
Message: <3c0b0260@news.povray.org>
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!




//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}
 }
 object {X_View translate -y*Rounding}
}

#declare Y_R = 2;
#declare Y_Start_Z = 1;
#declare Y_End_Z = -1.5;
#declare Start_Y = sqrt(Y_R^2-Y_Start_Z^2);
#declare End_Y = sqrt(Y_R^2-Y_End_Z^2);
#declare Start_A = -degrees(asin(Start_Y/Y_R));
#declare End_A = degrees(asin(End_Y/Y_R));

union
{
 #declare B = Start_A;
 #while (B<=End_A)
  #declare PosY = (vrotate(y*2,x*B)+<0,-0.5,0.25>)*<1.25,1,1/1.25*2.8>;
   #switch(PosY.z)
   #range(-2.8,-0.25)
    #declare Pos1X = sqrt(1-(PosY.z/2.8)^2)*(1.25-Rounding);
    #declare Pos1 = < Pos1X,PosY.y-Rounding,PosY.z-Rounding*SIGN(PosY.z)>;
    #declare Pos2 = <-Pos1X,PosY.y-Rounding,PosY.z-Rounding*SIGN(PosY.z)>;
    sphere {Pos1,Rounding}
    sphere {Pos2,Rounding}
   #break
   #range(-0.25,0.25)
    #declare Pos1 = <
1.25-Rounding,PosY.y-Rounding,PosY.z-Rounding*SIGN(PosY.z)>;
    #declare Pos2 =
<-1.25+Rounding,PosY.y-Rounding,PosY.z-Rounding*SIGN(PosY.z)>;
    sphere {Pos1,Rounding}
    sphere {Pos2,Rounding}
   #break
   #range(0.25,2.8)
    #declare Pos1X = sqrt(1-(PosY.z/2.8)^2)*(1.25-Rounding);
    #declare Pos1 = < Pos1X,PosY.y-Rounding,PosY.z-Rounding*SIGN(PosY.z)>;
    #declare Pos2 = <-Pos1X,PosY.y-Rounding,PosY.z-Rounding*SIGN(PosY.z)>;
    sphere {Pos1,Rounding}
    sphere {Pos2,Rounding}
   #break
   #end
  #declare B = B + 0.01;
 #end
}


Post a reply to this message

From: Mike Williams
Subject: [EMERGENCY] - Help with geometry...
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

From: Rune
Subject: Re: [EMERGENCY] - Help with geometry...
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

From: Rune
Subject: Re: [EMERGENCY] - Help with geometry...
Date: 3 Dec 2001 16:50:03
Message: <3c0bf38b@news.povray.org>
"Mike Williams" wrote:
> 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.

Hmm, seems like we came up with the exact same method.

But you forgot to take into account the fact that the spheres stick up
slightly of the surface on all non-horizontal surfaces, i.e. everywhere.
Thus the edge is not 100% smooth in your version...

Sorry, I had to point that out... :)

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Nov 5)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Tony[B]
Subject: Re: [EMERGENCY] - Help with geometry...
Date: 3 Dec 2001 20:54:24
Message: <3c0c2cd0@news.povray.org>
> 1) I hope you get this in time.

Nope. Didn't.

> 2) I hope it is a *really* important emergency.

Not really. I managed to get by without the mouse being rounded.

> 3) I hope nobody beat me to it.

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

Sorry. And thanks!


Post a reply to this message

From: Tony[B]
Subject: Re: [EMERGENCY] - Help with geometry...
Date: 3 Dec 2001 20:54:49
Message: <3c0c2ce9@news.povray.org>
Thanks. I was really hoping for a method that didn't use trace(). Oh, well.


Post a reply to this message

From: Rune
Subject: Re: [EMERGENCY] - Help with geometry...
Date: 4 Dec 2001 16:12:41
Message: <3c0d3c49@news.povray.org>
"Tony[B]" wrote:
> > 1) I hope you get this in time.
>
> Nope. Didn't.

Oh well... Time spend with POV-Ray is never completely wasted...

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Nov 5)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

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