POV-Ray : Newsgroups : povray.newusers : rounding : Re: rounding Server Time
28 Jul 2024 16:16:50 EDT (-0400)
  Re: rounding  
From: Stephen
Date: 25 Jun 2008 05:26:03
Message: <lo34645hsfub8cn0ukmhudsrjboe30fid4@4ax.com>
On Wed, 25 Jun 2008 05:11:06 EDT, "stevenvh" <nomail@nomail> wrote:

>I'm surprised (and a bit pissed off) not to find a means to round a number to
>the nearest integer.
>I want to use the rand() function to randomly generate a rotation angle which is
>a multiple of 90 degrees, which I would write in any programming language I know
>as
>
>  RotAngle = 90 * round(4 * rand(RandSeed))
>
>How should I do this in POV-Ray?
>TIA
>Steven
>

There is 
ceil(A) Ceiling of A. Returns the smallest integer greater than A.
Rounds up to the next higher integer.

And

floor(A) Floor of A. Returns the largest integer less than A. Rounds
down to the next lower integer.

And you can use A - int(A) to see if the fractional part is > 0.5

-- 

Regards
     Stephen


Post a reply to this message

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