Notifications
Clear all
[Closed] 0 vs -3.8147e-006
Jul 14, 2012 5:02 pm
In one of my script I need to know if the object Z position is equal to 0, but, sometimes max prints
obj.pos.z = 0.0
, sometimes –
obj.pos.z = -3.8147e-006
.
I use this code for testing if the obj position is equal to 0
if obj.pos.z == 0 or (matchPattern (obj.pos.z as string) pattern:"*e*") then... else...
This not work:
close_enough (-3.8147e-006) 0 1
Is there another way of detecting that -3.8147e-006 is 0?
5 Replies
1 Reply
this is just wrong…
if obj.pos.z == 0 or (matchPattern (obj.pos.z as string) pattern:"*e*") then... else...
it might any number in e pattern…
do something :
if abs (z) < 0.000001 do ...
Jul 14, 2012 5:02 pm
by the way… you can find my roundFloat function on this forum. it’s what i use instead of the close_enough
Jul 14, 2012 5:02 pm
http://forums.cgsociety.org/showthread.php?f=98&t=821755&highlight=roundFloat
Is it that one that you are talking about Denis?
Jul 14, 2012 5:02 pm
Yes, PEN. I found it, but I need only to know if the value is zero or not, so I start using obj.pos.z < 0.000001.