api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Empty Geom::BoundingBox instance methods return strange point objects

Open DanRathbun opened this issue 8 years ago • 4 comments

SketchUp Ruby API Issue

1. SketchUp/LayOut Version:

SketchUp

2. OS Platform:

Both

3. Describe briefly what you are doing and what is happening.

Empty Geom::BoundingBox instance methods return strange point objects with crazy large coordinates.

This might contribute to geometry FAR from the origin, if these coordinates are used to create geometry (in error.)

4. Describe what the expected result is.

I was expecting either an exception raised, or query methods to return nil until the bounding box becomes valid.

Perhaps Geom module could benefit from a new Geom::GeometryError exception subclass ?

bb.corner(3)
#=> Error: #<Geom::GeometryError: invalid Geom::BoundingBox instance for method :corner.>

It also brings up the idea that perhaps Geom::Point3d class needs #valid? checking method.

5. Reproducible code snippet:

b1 = Geom::BoundingBox.new
#<Geom::BoundingBox:0x0000000c5e85b0>
b1.corner(0)
#=> (1000000000000000000000000000000",
#=>  1000000000000000000000000000000", 
#=>  1000000000000000000000000000000" )
p8 = b1.corner(7)
#=> (-1000000000000000000000000000000",
#=>  -1000000000000000000000000000000",
#=>  -1000000000000000000000000000000" )

I've never seen Point3d coordinates this large before ! That many inches is like: 15782828282828282828282828 miles. These numbers are on the order of 1668246265.8206708 lightyears ! That's the distance light travels in 1.67 BILLION earth years.

DanRathbun avatar Dec 20 '17 14:12 DanRathbun

Hm... What version of SketchUp is this observed in?

thomthom avatar Dec 22 '17 14:12 thomthom

@thomthom Hm... What version of SketchUp is this observed in?

I'm seeing it in 2016 64-bit Ruby 2.0.0.

DanRathbun avatar Dec 22 '17 15:12 DanRathbun

I see it as far back as SU2014 (didn't try any further). Wonder if it could be uninitialized variables...

Logged as SU-38425

thomthom avatar Jan 03 '18 12:01 thomthom

Yea, happens on SU2013 as well.

And the numbers are not even as Point3d coords show ...

b1.corner(0)[0].to_i
#=> 1000000000000000019884624838656

DanRathbun avatar Jan 03 '18 20:01 DanRathbun