POV-Ray : Newsgroups : povray.newusers : Scaling question... : Re: Scaling question... Server Time
30 Jul 2024 22:23:20 EDT (-0400)
  Re: Scaling question...  
From: Carl Hoff
Date: 28 Nov 2003 12:56:44
Message: <3fc78c5c@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
> That's odd. The isosurface I posted does join smoothly with the two
> capping ellipsoids shown above. All you have to do is use the same
> values for a1, a2, b1, b2 and x0.

Well I said I gave up.  I must not have as I woke up this morning with
another idea stuck in my head.  Seems I do my best problem solving
while I'm not trying to problem solve.  Anyways... I'm now half way
there.  Try out this code.  It joins two ellipsoids with TWO Supercones
and it joins up with the larger ellipsoid perfectly.  However at the
end of the smaller ellipsoid the shape still ends up inside the ellipsoid
at all but 4 points.  I have one other idea that I want to try but without
doing it I'm not sure if its not mathmatically equivalent to what I just did
here.

Enjoy,
Carl

  #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;

  sphere{center1,radius1 scale<1,1,maxz/radius1> pigment{Red}}
  sphere{center2,radius2 scale<1,1,maxz/radius2> pigment{Green}}

  declare center = (center1+center2)/2;

  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}
  camera {location center-500*z look_at center angle 27}

  object {zellipsoid2fill(center1,radius1,center2,radius2,maxz)
pigment{Blue}}


Post a reply to this message

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