( [ 0,0,0 ].vector_to( [ 0,0,0 ] ) ).length.mm < 0.01.mm
-
is this "true" or "false"?:
( [ 0,0,0 ].vector_to( [ 0,0,0 ] ) ).length.mm < 0.01.mmon my computer it is "false" - and I dont know why?
-
SketchUp's Length class uses some default tolerance in its comparisons - the tolerance is not documented as far as I know.
@unknownuser said:
The equality comparison on Length values uses the default tolerance that SketchUp uses for comparing lengths
In SketchUp-land:
> 0.01.mm == 0 #==> trueSearch the following page for "tolerance"
http://www.sketchup.com/intl/en/developer/docs/ourdoc/length
-
nullvec = Geom;;Vector3d.new(0,0,0) l1 = nullvec.length.mm # obviously 0 mm or 0 inch l2 = 0.01.mm # 0.000393700787401575 inch l1 == l2 β truebut
0 < 0.000393700787401575 β trueThis is because #mm or #to_mm etc. are methods that return an object of the Length class, not a Float. A Length is a Float that considers SketchUp's tolerance, which is currently set to 0.001 inch (we should never use this tolerance value directly since SketchUp might have the freedom to change it).
-
so to find the length of I should use length.to_f ?
-
@davidfi1 said:
so to find the length of I should use length.to_f ?
To treat it as a float you must use
to_f, yes. The numeric value of the objects are the same. The only difference of theLengthwhich is a sub-class ofFloatis the comparison operators.( [ 0,0,0 ].vector_to( [ 0,0,0 ] ) ).length.to_f < 0.01.mm
That works because you're now dealing with the standard floating point comparisons. Not knowing what your experience with floating points are, but just in case; here's a very informative site on the topic: http://floating-point-gui.de/ -
Very informative site in did.
Thank you.
I am a hardware engineer by training - so I know this problem from the other side
and still it is a little strange
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement