POV-Ray : Newsgroups : povray.advanced-users : elliptical cone? : Re: elliptical cone? Server Time
30 Jul 2024 12:23:37 EDT (-0400)
  Re: elliptical cone?  
From: Nieminen Mika
Date: 29 Jul 1999 08:28:02
Message: <37a048d2@news.povray.org>
The formula of an elliptical cylinder along the z-axis is the following:

x^2/r1^2 + y^2/r2^2 = 1

where 'r1' and 'r2' are the radiuses of the ellipse.
  What we want is this kind of cylinder which changes linearly from z=0 to
z=1 so that in z=0 the ellipse has radiuses 'a' and 'b' and in z=1 radiuses
'c' and 'd'.
  This means that when z=0, r1=a and r2=b. Then r1 and r2 should linearly
change so that when z=1, r1=c and r2=d.
  This can be expressed this way:

r1 = a*(1-z)+c*z
r2 = b*(1-z)+d*z

  Substituting in the above formula we get:

x^2/(a*(1-z)+c*z)^2 + y^2/(b*(1-z)+d*z)^2 = 1

  That's it. Now we have to reduce that to polynomial form so that we can
write the quartic. This is a quite laborious job. I will not type the
polynom here because it's so long, but it begins this way:

b^2*x^2 + 2*(b*d-b^2)*x^2*z + (b^2-2*b*d+d^2)*x^2*z^2 + ... and so on

  Now, to write the polynomial, we look at the table in the page 212 of the
povray manual (the "Poly, Cubic and Quartic"-section). We place all the
terms of the polynomial in the right places in the vector. The result is:

quartic
{ <0, 0,  0,  0, 0,   0,   0,  b*b-2*b*d+d*d, 2*(b*d-b*b), b*b,
   0,  0,   0,  0,   0,  0, 0,  0,  0, 0,
   0, 0,  0, a*a-2*a*c+c*c, 2*(a*c-a*a), a*a, 0,  0,  0, 0,
   -(a*a-2*a*c+c*c)*(b*b-2*b*d+d*d),
   -(2*((b*d-b*b)*(a*a-2*a*c+c*c)+(a*c-a*a)*(b*b-2*b*d+d*d))),
   -(b*b*(a*a-2*a*c+c*c)+4*(a*c-a*a)*(b*d-b*b)+a*a*(b*b-2*b*d+d*d)),
   -(2*(b*b*(a*c-a*a)+a*a*(b*d-b*b))), -a*a*b*b>
}

  Now we only have to cut the unwanted parts out (ie. everything that is
at z<0 and z>1) and bound with a proper object for speedup.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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