POV-Ray : Newsgroups : povray.general : Pattern function errors Server Time
30 Jul 2024 18:20:17 EDT (-0400)
  Pattern function errors (Message 1 to 6 of 6)  
From: SharkD
Subject: Pattern function errors
Date: 6 Jul 2008 23:55:00
Message: <web.487192ebe6f38171eb867ce10@news.povray.org>
I am having problems with the following pattern:

pigment
{
 function {sqrt(pow(x,2) + pow(z,2)) / cos(asin(abs(y)))}
 pigment_map
 {
  [0 color rgb 0]
  [1 color rgb <0,1,0,>]
 }
}

POV-Ray gives the following error:

"Parse Error: Floating-point exception detected in function ''. Your function
either attempted a division by zero, used a function outside
its domain or called an internal function with invalid parameters."

Could somebody please explaing to me why this is and what I can do to fix it?

-Mike


Post a reply to this message

From: Tim Nikias
Subject: Re: Pattern function errors
Date: 7 Jul 2008 02:39:58
Message: <4871ba3e@news.povray.org>
SharkD wrote:
> I am having problems with the following pattern:
> 
> pigment
> {
>  function {sqrt(pow(x,2) + pow(z,2)) / cos(asin(abs(y)))}
>  pigment_map
>  {
>   [0 color rgb 0]
>   [1 color rgb <0,1,0,>]
>  }
> }
> 
> POV-Ray gives the following error:
> 
> "Parse Error: Floating-point exception detected in function ''. Your function
> either attempted a division by zero, used a function outside
> its domain or called an internal function with invalid parameters."
> 
> Could somebody please explaing to me why this is and what I can do to fix it?

The Error says it all: You're dividing by zero. Somewhere along the 
cosine of asin(abs(y)) the result is 0, which is what you'll be dividing by.

Regards,
Tim


Post a reply to this message

From: SharkD
Subject: Re: Pattern function errors
Date: 7 Jul 2008 03:30:01
Message: <web.4871c5b183e204bdeb867ce10@news.povray.org>
Tim Nikias <JUS### [at] gmxnetWARE> wrote:
> SharkD wrote:
> > I am having problems with the following pattern:
> >
> > pigment
> > {
> >  function {sqrt(pow(x,2) + pow(z,2)) / cos(asin(abs(y)))}
> >  pigment_map
> >  {
> >   [0 color rgb 0]
> >   [1 color rgb <0,1,0,>]
> >  }
> > }
> >
> > POV-Ray gives the following error:
> >
> > "Parse Error: Floating-point exception detected in function ''. Your function
> > either attempted a division by zero, used a function outside
> > its domain or called an internal function with invalid parameters."
> >
> > Could somebody please explaing to me why this is and what I can do to fix it?
>
> The Error says it all: You're dividing by zero. Somewhere along the
> cosine of asin(abs(y)) the result is 0, which is what you'll be dividing by.
>
> Regards,
> Tim

I've tried changing the denominator of the fraction to
max(cos(asin(abs(y))),0.001) so that it doesn't divide by zero, but it has no
effect.

-Mike


Post a reply to this message

From: Mike Williams
Subject: Re: Pattern function errors
Date: 7 Jul 2008 04:42:13
Message: <OuZ4ZaDSbdcIFwJd@econym.demon.co.uk>
Wasn't it SharkD who wrote:
>I am having problems with the following pattern:
>
>pigment
>{
> function {sqrt(pow(x,2) + pow(z,2)) / cos(asin(abs(y)))}
> pigment_map
> {
>  [0 color rgb 0]
>  [1 color rgb <0,1,0,>]
> }
>}
>
>POV-Ray gives the following error:
>
>"Parse Error: Floating-point exception detected in function ''. Your function
>either attempted a division by zero, used a function outside
>its domain or called an internal function with invalid parameters."
>
>Could somebody please explaing to me why this is and what I can do to fix it?

The problem is that asin(foo) is only defined for values of foo between 
-1 and +1. If, say y=3 then there is no asin(abs(3)) and you get the 
second cause of that error message "your function ... used a function 
outside its domain"

If you apply the pigment to an object that lies between y=-1 and y=1, 
then it works.

sphere {0,1
  scale <5,0.5,5>
  pigment{
   function {sqrt(pow(x,2) + pow(z,2)) / cos(asin(abs(y)))}
   pigment_map {
    [0 color rgb 0]
    [1 color rgb <0,1,0,>]
   }
  }
}

If you want to use it on an object that doesn't lie within that region, 
then you need to consider what colour you want to have for points 
outside that region and code it accordingly.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Tim Nikias
Subject: Re: Pattern function errors
Date: 7 Jul 2008 06:23:33
Message: <4871eea5@news.povray.org>
SharkD wrote:
>>> POV-Ray gives the following error:
>>>
>>> "Parse Error: Floating-point exception detected in function ''. Your function
>>> either attempted a division by zero, used a function outside
>>> its domain or called an internal function with invalid parameters."
>>>
>>> Could somebody please explaing to me why this is and what I can do to fix it?

>> The Error says it all: You're dividing by zero. Somewhere along the
>> cosine of asin(abs(y)) the result is 0, which is what you'll be dividing by.

> I've tried changing the denominator of the fraction to
> max(cos(asin(abs(y))),0.001) so that it doesn't divide by zero, but it has no
> effect.

Mike Williams has the answer, its not just division by zero, but asin(x) 
doesn't return proper results for values outside of the -1 to 1 range.

Regards,
Tim


Post a reply to this message

From: SharkD
Subject: Re: Pattern function errors
Date: 7 Jul 2008 10:55:04
Message: <web.48722d2383e204bd4d862de40@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> If you want to use it on an object that doesn't lie within that region,
> then you need to consider what colour you want to have for points
> outside that region and code it accordingly.

Thanks for the answer!

What's odd is that you can't scale the pigment either. For instance, the
following produces errors.

sphere {0,1
  pigment{
   function {sqrt(pow(x,2) + pow(z,2)) / cos(asin(abs(y)))}
   pigment_map
   {
    [0 color rgb 0]
    [1 color rgb <0,1,0,>]
   }
 scale y/2
 translate y
  }
}

Shouldn't the function be evaluated to completion before the pigment gets
scaled?

-Mike


Post a reply to this message

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