POV-Ray : Newsgroups : povray.newusers : rounding : Re: rounding Server Time
28 Jul 2024 16:25:08 EDT (-0400)
  Re: rounding  
From: How Camp
Date: 25 Jun 2008 07:40:00
Message: <web.48622e8142ba7542c59235590@news.povray.org>
"stevenvh" <nomail@nomail> wrote:
>   RotAngle = 90 * round(4 * rand(RandSeed))
>
> How should I do this in POV-Ray?


Trevor Quayle posted this helpful function a while ago that rounds 'a' to the
nearest 'b' decimal places:


#declare Round=function
(a,b){select(a,-1,1)*int(abs(a)*pow(10,b)+0.5)/pow(10,b)}



The original is here:

http://news.povray.org/povray.advanced-users/thread/%3Cweb.4739e4827567ddbb94e61a50@news.povray.org%3E/

- How


Post a reply to this message

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