I got smacked by this morning…..
I have a Sequence Blend blending between two SOPs.
If have an expression
fit(frac($FF),0,.4,0,1) set for the blend parameter. The neat part is, the Blend SOP fails when $FF = 1.4. (If $FF = 2.4 or 3.4 etc it works fine.)
So upon further testing..
fcur 1.4
echo `frac($FF)==0.4`
Returns 0.
Which is fair enough considering your never suppose to do direct comparisions, ==, between floats.
Even further testing….
Changing
fit(frac($FF),0,.4,0,1)
to
fit(frac($FF),0,.4,0,.999)
Fixes the problem.
So, back to the question… If the Sequence Blend works with any number why is the expression failing? NaN?
Sequence Blend and Floats.
2514 2 0- wolfwood
- Member
- 4256 posts
- Joined: July 2005
- Online
- tsang
- Member
- 57 posts
- Joined: July 2005
- Offline
frac(x) is implemented as x - floor(x).
Due to floating point precision, frac(1.4) does not return 0.4 but a value slightly less than 0.4. Try
echo `1.4-floor(1.4)-0.4`
or better yet
echo `1.4-1.0-0.4`
now try
echo `2.4-2.0-0.4`
and
echo `3.4-3.0-0.4`
Notice that for 2.4 and 3.4, you get a value slightly positive while for 1.4 you get a value slightly negative. When you feed these frame values into your expression, you get values equal to 1 and slightly less than one respectively for the blend factor. The Sequence Blend SOP did not handle the slightly less than 1 case. This is now fixed in 8.0.452 (Bug ID=20924).
Due to floating point precision, frac(1.4) does not return 0.4 but a value slightly less than 0.4. Try
echo `1.4-floor(1.4)-0.4`
or better yet
echo `1.4-1.0-0.4`
now try
echo `2.4-2.0-0.4`
and
echo `3.4-3.0-0.4`
Notice that for 2.4 and 3.4, you get a value slightly positive while for 1.4 you get a value slightly negative. When you feed these frame values into your expression, you get values equal to 1 and slightly less than one respectively for the blend factor. The Sequence Blend SOP did not handle the slightly less than 1 case. This is now fixed in 8.0.452 (Bug ID=20924).
- wolfwood
- Member
- 4256 posts
- Joined: July 2005
- Online
-
- Quick Links