Archived

This topic is now archived and is closed to further replies.

sign()?

This topic is 5381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve reading the Ray(/segment)-triangle intersection tests for dummies at Cfxweb (http://www.cfxweb.net/modules.php?name=News&file=article&sid=1308) and want to know what the hell is the sign() function used at the pseudo codes from that article.

Share this post


Link to post
Share on other sites
I don''t know but here''s my guess: It''s a programmer(you)-defined function that returns a boolean TRUE or a boolean FALSE. One could simply say, by taste, that if it returned a 1, then the variable that was passed in as the parameter is negative. The "sign" is the +/- in front of the number. The sign of -1 is the "-", or minus sign. Floats in memory have one bit dedicated to the sign of the number. Ofcourse if the number part of the float is 0000000..., then there is no sign but a neutral one. In this case, the sign bit doesn''t have to be read...?

Share this post


Link to post
Share on other sites
It returns 0 if x=0, 1 if x>0 and -1 otherwise. It is one of a few functions used to describe discontineous functions as though they were contineous. You also have Kronecker delta which returns 1 if the two parameters are equal and zero otherwise. The antisyymmetric tensor function which returns 0 if any two of the three parameters are the same, 1 for even permutations and -1 for odd permutatations where the three parameters are limited to 0, 1 and 2. The heavyside step function whic returns 0 when x<0 and 1 otherwise.

Overall it is pretty much like using the absolute value function. Mainly it is useful in mathematical equations. It is easy to express conditional logical in a function within a program, but a little more cumbersome in a mathmatical equation.

Share this post


Link to post
Share on other sites