Path: utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!ncar!boulder!ccncsu!handel.colostate.edu!bullerj From: bullerj@handel.colostate.edu (Jon Buller) Newsgroups: comp.graphics Subject: Re: Pixar's noise function Keywords: random numbers, Byte, elephants Message-ID: <1669@ccncsu.ColoState.EDU> Date: 17 Apr 89 15:08:22 GMT References: <2553@ssc-vax.UUCP> <3599@pixar.UUCP> <97699@sun.Eng.Sun.COM> <1592@ccncsu.ColoState.EDU> <43327@tut.cis.ohio-state.edu> <1648@ccncsu.ColoState.EDU> <1771@skinner.nprdc.arpa> Sender: news@ccncsu.ColoState.EDU Reply-To: bullerj@handel.colostate.edu.UUCP (Jon Buller) Organization: Colorado State University, Ft. Collins CO 80523 Lines: 27 In article <1771@skinner.nprdc.arpa> malloy@nprdc.arpa (Sean Malloy) writes: >If I understand the problem correctly, writing a floor() function is >extremely simple: >int floor(x) >double x; >{ > if (x >= 0.0) return(trunc(x)); > else return(trunc(x)+1); >} > Sean Malloy | "The proton absorbs a photon > Navy Personnel Research & Development Center | and emits two morons, a > San Diego, CA 92152-6800 | lepton, a boson, and a > malloy@nprdc.navy.mil | boson's mate. Why did I ever > | take high-energy physics?" I like this ^^^^^^ 8-) Well, that almost works, if x = -1.0, floor = -1.0, your_func = 0.0 (you meant return(trunc(x)-1); didn't you?) in this case, your_func = -2.0, this ----> ^^^^^^^^ will work if x is NOT an integer, will break if it is, and it is admittedly a simple thing to fix, but as I said before, I've been LAZY. I can't use the thing in a render quite yet, so I haven't bothered. ------------------------------------------------------------------------------- Jon Buller FROM fortune IMPORT quote; ..!ccncsu!handel!bullerj FROM lawyers IMPORT disclaimer;