POV-Ray : Newsgroups : povray.binaries.images : A masked ellipsoid... Server Time
19 Nov 2024 10:20:26 EST (-0500)
  A masked ellipsoid... (Message 1 to 1 of 1)  
From: Carl Hoff
Subject: A masked ellipsoid...
Date: 28 Nov 2003 14:26:14
Message: <3fc7a156@news.povray.org>
Here is a picture to go along with my posts over in the newusers area.

What I'm trying to do is define the shape needed to fill the area between
two ellipsoids that have the same z extent and are in the same z plane.
Sort of something like a linear ellipsoid sweep akin to the sphere_sweep
command.

Note my try here works perfectly to match up to the larger ellipsoid but
fails on the side of the smaller ellipsoid.  I need to remove the 'eyes'
which I believe to be created because the fill shape shouldn't intersect
the smaller ellipsoid in two planes like it does the larger one.

If you can do any better then I've done PLEASE let me know.

Thanks,
Carl

Here is the code used to make this picture:

  #include "colors.inc"
  #include "math.inc"
  #include "transforms.inc"
  #include "shapes.inc"

  #macro zellipsoid2fill(V1,R1,V2,R2,R3)

    // V1 = center of sphere1
    // R1 = radius of sphere1
    // V2 = center of sphere2 NOTE: must be in the same z plane as sphere1
    // R2 = radius of sphere2
    // R3 = the new radius of both ellipsoids in the z direction

    #local V2a = V2-V1;
    #local angle_z1 = VRotationD(<V2a.x, V2a.y, 0>, x, z);
    #local V2b = vaxis_rotate(V2a, z, angle_z1);
    #local theta = degrees(asin((R1-R2)/V2b.x));
    #local V2c = vaxis_rotate(V2b, z, theta);
    #local maxyR = max(R1,R2);
    #local maxx = max(V2b.x+R2*sin(radians(theta)),V2b.x);
    #local minx = min(R1*sin(radians(theta)),0);
    #local shearx1 = <V2c.x, V2c.y, 0>/V2b.x;
    #local shearx2 = <V2c.x, -V2c.y, 0>/V2b.x;

    #local shape1 = object{Supercone(<0,0,0>, R3, R1, <V2b.x, 0, 0>, R3,
R2)}

    #local shape2 = intersection {
      object { shape1 Shear_Trans(shearx1,y,z) rotate -z*theta}
      box {<minx, 0, -R3>,<maxx,maxyR,R3>}
    }

    #local shape3 = intersection {
      object { shape1 Shear_Trans(shearx2,y,z) rotate z*theta}
      box {<minx, 0, -R3>,<maxx,-maxyR,R3>}
    }

    merge {
      object {shape2}
      object {shape3}
      rotate -z*angle_z1
      translate V1
    }
  #end

  declare center1 = <0,0,0>;
  declare radius1 = 50;
  declare center2 = <70,30,0>;
  declare radius2 = 20;
  declare maxz = 10;

  declare center = (center1+center2)/2-20*x;

  light_source {center-900*x-100*z White}
  light_source {center-900*y-100*z White}
  light_source {center+900*x+900*y-100*z White}
  light_source {center-500*z-50*x-50*y White}
  light_source {center+500*z-50*x-50*y White}
  camera {location center-500*z look_at center angle 22}

  #declare shape = merge {
    sphere{center1,radius1 scale<1,1,maxz/radius1> pigment{Red}}
    sphere{center2,radius2-0.03 scale<1,1,maxz/radius2> pigment{Green}}
    object {zellipsoid2fill(center1,radius1,center2,radius2,maxz)
pigment{Blue}}
  }

  object {shape}
  object {shape rotate x*90 translate 70*y}


Post a reply to this message


Attachments:
Download 'esweep2.jpg' (79 KB)

Preview of image 'esweep2.jpg'
esweep2.jpg


 

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