Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
Odd Math
-
Can anyone explain the results of this snippet?
model = Sketchup.active_model entities = model.entities selection = model.selection camera = model.active_view.camera cdir = camera.direction puts "camera dir; #{ cdir.inspect}" sum = cdir.x.abs + cdir.y.abs + cdir.z.abs puts "sum; #{sum.inspect}" puts "sum == 1? #{sum == 1}"Results:
camera dir; Vector3d(0, 1, 0) sum; 1 sum == 1? false -
Yes. .to_s / .inspect print an approximation of the Float value. When it prints (0,1,0), thats just the answer to 4 significant figures. Your Float(1) comparison simply shows that difference.
-
Thanks Adam. I still don't understand why sum (which is a Float)shown as 1 instead of 1.0
Might the .inspect method be over-ridden?
Advertisement