POV-Ray : Newsgroups : povray.general : Check this out!!! : Re: Check this out!!! Server Time
12 Aug 2024 17:16:27 EDT (-0400)
  Re: Check this out!!!  
From: Jerry Anning
Date: 24 Feb 1999 17:31:34
Message: <36d479a6.24621457@news.povray.org>
On Wed, 24 Feb 1999 23:35:47 +0200, "Margus Ramst"
<mar### [at] peakeduee> wrote:

>
>Jerry Anning wrote in message <36d2ed6f.2561587@news.povray.org>...
>>
>>I coded it as a macro using the parametric object in SuperPatch.  For
>>some reason, it works fine with exponents of 1.0 (regular torus) but
>>gives garbage for any other exponent.  Is it the parametric object,
>>the equations in the referenced page or my bad coding?  I am going to
>>redo it as a mesh object with those equations and see what happens.
>>If anyone else wants to play with this, here is the macro I used.  To
>>repeat, it uses the SuperPatch.  Sorry about the underscores and
>>indenting, Ken!
>>
>
>Arrghh!!!! I can't get it to work at all.
>Like this:
>isosurface{Supertoroid(1,.3,1,1)}
>Error: function is not defined
>
>Like this:
>isosurface{function{Supertoroid(1,.3,1,1)}}
>Error: no matching brace in function
>
>Like this:
>#declare S=Supertoroid(1,.3,1,1)}
>isosurface{S}
>POV crashes (page fault in povray.exe)
>
>If I add precompute to Supertoroid, the scene renders, but the isosurface is
>just a box.
>I must admit, this is the first time I tried the parametric{} isosurface, so
>i may be doing something real stupid. But the crashing is suspicious. Maybe
>a bug?

>Margus.

First, the parametric object is an independent type in its own right,
not an isosurface function.  The macro simply wraps a parametric
*object* up and makes it easily usable.  Second, there seems to be an
issue about using #declare or #local with the parametric object.
Every variation of that that I try goes straight to GPF city during
the parse.  Third, as Ron Parker mentioned, the parametric object
seems to want to be first quadrant only.  Since the supertoroid has
suitable symmetry, you can get around that by making four rotated
copies of the object.  Since #declare is out, you have to splat four
actual copies of the parametric code into a union in the macro.  Here
is an (ugly, dog-slow) working version of the macro with a demo of how
to call it:

// Begin POV code

// _Rj is major radius
// _Rn is minor radius
// _E1 and _E2 are exponents

#macro Supertoroid(_Rj, _Rn, _E1, _E2)
  union
    {
      parametric
        {
          function (cos(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(v) ^ _E2) *  _Rn
          <0, 0>, <2 * pi, 2 * pi>
          <-(_Rj + _Rn + .1), -(_Rj + _Rn + .1), -(_Rj +_Rn +.1)>,
          <_Rj +_Rn + .1, _Rj + _Rn + .1, _Rj + _Rn + .1>
          accuracy .001
          rotate <90, 0, 0>
        }
      parametric
        {
          function (cos(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(v) ^ _E2) *  _Rn
          <0, 0>, <2 * pi, 2 * pi>
          <-(_Rj + _Rn + .1), -(_Rj + _Rn + .1), -(_Rj +_Rn +.1)>,
          <_Rj +_Rn + .1, _Rj + _Rn + .1, _Rj + _Rn + .1>
          accuracy .001
          rotate <90, 0, 0>
          rotate <0, 90, 0>
        }
      parametric
        {
          function (cos(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(v) ^ _E2) *  _Rn
          <0, 0>, <2 * pi, 2 * pi>
          <-(_Rj + _Rn + .1), -(_Rj + _Rn + .1), -(_Rj +_Rn +.1)>,
          <_Rj +_Rn + .1, _Rj + _Rn + .1, _Rj + _Rn + .1>
          accuracy .001
          rotate <90, 0, 0>
          rotate <0, 180, 0>
        }
      parametric
        {
          function (cos(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(u) ^ _E1) * (_Rj + _Rn * (cos(v) ^ _E2)),
                   (sin(v) ^ _E2) *  _Rn
          <0, 0>, <2 * pi, 2 * pi>
          <-(_Rj + _Rn + .1), -(_Rj + _Rn + .1), -(_Rj +_Rn +.1)>,
          <_Rj +_Rn + .1, _Rj + _Rn + .1, _Rj + _Rn + .1>
          accuracy .001
          rotate <90, 0, 0>
          rotate <0, 270, 0>
        }
    }
#end

// End POV code

You call it like this:

// Begin POV code

object
  {
    Supertoroid(8, 3, 2, .5)
    texture
      {
        pigment { color Red }
        normal { dents 2 scale <.1, 3, .2> }
        finish { specular 1 roughness .002 }
      }
    rotate <-30. -30, 0>
  }

// End POV code

I will post the mesh version somewhere in a day or so.  Should be much
faster to render, although slower to parse.  Good luck.

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

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