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 12:17:05 EDT (-0400)
  Re: Megpov: how to do a superelipse? Do we need x^p=sign(x)*|x|^p?  
From: Christoph Hormann
Date: 5 Jan 2001 04:41:59
Message: <3A5596E8.6A443CE0@gmx.de>
Tor Olav Kristensen wrote:
> 
> > >
> > > x^n = exp(n*ln(x))
> >
> > Uh, I think "x^n = pow(x, n)" is more likely...
> 
> Yes, but do you know how this is actually computed ?
> 

<remembering something>
<digging through harddisk>

\Delphi4\Source\Rtl\Sys\Math.pas:

function Power(Base, Exponent: Extended): Extended;
begin
  if Exponent = 0.0 then
    Result := 1.0               { n**0 = 1 }
  else if (Base = 0.0) and (Exponent > 0.0) then
    Result := 0.0               { 0**n = 0, n > 0 }
  else if (Frac(Exponent) = 0.0) and (Abs(Exponent) <= MaxInt) then
    Result := IntPower(Base, Integer(Trunc(Exponent)))
  else
    Result := Exp(Exponent * Ln(Base))
end;

Seems Tor is right, since i guess the C function pow(x,y) computes the
same (maybe apart from the optimization done here) this again answers the
questions about where it is defined.  

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

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