POV-Ray : Newsgroups : povray.binaries.images : Megpov: how to do a superelipse? Do we need x^p=sign(x)*|x|^p? : Re: Megpov: how to do a superelipse? Do we need x^p=sign(x)*|x|^p? Server Time
19 Aug 2024 06:26:18 EDT (-0400)
  Re: Megpov: how to do a superelipse? Do we need x^p=sign(x)*|x|^p?  
From: Tor Olav Kristensen
Date: 3 Jan 2001 20:49:01
Message: <3A53D643.959D0047@online.no>
"Greg M. Johnson" wrote:
> 
> Why can't I get a working superellipse?
> 
> See code below and image below.  It looks like I'm losing two quadrants
> of the s-e. Note that when the n2 is changed to 1.0 I get a nice sphere.
> 
> I then read in a web page for CS from U of Western Australia:
> http://www.cs.uwa.edu.au/undergraduate/units/600.105/Lab6.html
> 
> > Note for this representation to work `exponentiation' must be defined 
> as
> >      p                   p
> >    x   =  sign(x) |x|
> >
> > Where the sign function returns +1 for +ve x, 0 for 0 x, and -1 for
> -ve x.
> > This allows exponentiation to `work' for  arbitrary x and p.
> >
> 
> I tried coding this into my parametric using the abs() function, BUT
> mega said I had too many parameters.....

See code below.


> I remember asking about exactly how povray did the exponents ages ago,
> and perhaps here we have a concrete problem. Any pointers?


Maybe it is done like this ?

x^n = exp(n*ln(x))

If so, then ln(x) may not be defined for x <= 0


I'm too tired to write more, so I'm going to sleep now.


Regardzzzzz,

Tor Olav
-- 
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version unofficial MegaPov 0.5;

#include "colors.inc"

global_settings { ambient_light color White*2 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare n1 = 0.2;
#declare n2 = 0.2;

parametric {
  function
     abs(cos(u))^n1*if(cos(u), 1, -1)*abs(cos(v))^n2*if(cos(v), 1, -1),
     abs(cos(u))^n1*if(cos(u), 1, -1)*abs(sin(v))^n2*if(sin(v), 1, -1),
     abs(sin(u))^n1*if(sin(u), 1, -1)
     <-pi, -pi>, <pi, pi>
     <-1.1, -1.1, -1.1>, <1.1, 1.1, 1.1>
  accuracy 0.001
  precompute 15, [x, y, z]
  pigment { color White }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color Blue/2 }

light_source { <-3, 1, -1>*10 color White*2 }

camera {
  location <1, 1, -2>*1.5
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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