Skip to main content
14 events
when toggle format what by license comment
May 24, 2011 at 19:23 comment added aaaaaaaaaaaa @Lunin: Performance theory is a pretty neglected field, a lot of what people think they know where approximately correct 30 years ago when ALUs were big expensive and slow. Even the exponent function which you have just discovered to be a quite slow arithmetic function is rarely a highly significant performance sinner. Branching (using an if statement) and cache misses (reading a piece of data not currently residing in cache) are typically what cost the most performance.
May 24, 2011 at 18:01 comment added Lunin @eBusiness: I did not realize Math.Pow() was so slow, but your comment made me run a performance test between the two and you're right, it is considerably slower than Math.Sqrt(). However, if you know which power you are going for and that power is a whole number, you can relatively easily write an equivalent function yourself with significant gains over sqrt. Thank you for pointing this out though, I will be editing my answer to add this piece of information.
May 24, 2011 at 13:25 comment added aaaaaaaaaaaa I merely mentioned fast inverse square root to point out that a square root operation is not that expensive, in a modern environment you shouldn't use it explicitly. If it actually is the fastest method for a given platform then the compiler should implement it.
May 24, 2011 at 13:08 comment added aaaaaaaaaaaa @Joe Wreschnig, I did write equivalent (not equal), by which I mean a linear relation that cross the origin. The numbers have different units so of course they can't be equal.
May 24, 2011 at 12:15 comment added didito @Joe Wreschnig well, could still be useful on some mobile platforms
May 24, 2011 at 12:12 comment added didito @eBusiness & @Joe Wreschnig - "triangle distribution" is another good hint for me to research. looks very simplistic and useful. thx!
May 24, 2011 at 11:06 comment added user744 As an aside, fast inverse square root is a neat trick, but today we have instructions like rsqrtps, which will do them much faster and more accurately if that's your bottleneck. Either way, it is not something to worry about generally, and certainly not worse than arbitrary powers. (Square root is, after all, a power.)
May 24, 2011 at 11:00 comment added user744 @eBusiness: You're right. I don't know what I was thinking when I said it wasn't triangular, probably I'm too used to dealing with the a = c = 0 case of them. (However the probability of a position is still not equal to the position.)
May 23, 2011 at 22:34 comment added aaaaaaaaaaaa @Lunin, why are you complaining about the square root when you have got an exponent in your answer?
May 23, 2011 at 22:29 history edited aaaaaaaaaaaa CC BY-SA 3.0
added 494 characters in body
May 23, 2011 at 22:13 comment added aaaaaaaaaaaa @Joe Wreschnig, did you read that Wikipedia article yourself, stuff a=0, b=1, c=1 into the generation formula and you get the formula in my post.
May 23, 2011 at 20:25 comment added Lunin While sqrt gives some interesting patterns, particle systems generally need to be very CPU light per particle, so I would recommend avoiding square roots (which are computationally slow) where possible. You can sometimes get away with just pre-computing them, but it can make your particles have noticeable patters over time.
May 23, 2011 at 18:45 comment added user744 The probability of a position won't be equal to the position (that's mathematically impossible - trivially, the domain and range of the function includes both 0.50 and 0.51), nor is it a triangular distribution. (en.wikipedia.org/wiki/Triangular_distribution)
May 23, 2011 at 18:31 history answered aaaaaaaaaaaa CC BY-SA 3.0