Class: SkippyLib::BoundingBox
Overview
This class is different from Geom::BoundingBox
because it represent the
orientation in model space. The visible boundingbox one see in the viewport.
Constant Summary
SkippyLib::BoundingBoxConstants::BOTTOM_BACK_LEFT, SkippyLib::BoundingBoxConstants::BOTTOM_BACK_RIGHT, SkippyLib::BoundingBoxConstants::BOTTOM_FRONT_LEFT, SkippyLib::BoundingBoxConstants::BOTTOM_FRONT_RIGHT, SkippyLib::BoundingBoxConstants::TOP_BACK_LEFT, SkippyLib::BoundingBoxConstants::TOP_BACK_RIGHT, SkippyLib::BoundingBoxConstants::TOP_FRONT_LEFT, SkippyLib::BoundingBoxConstants::TOP_FRONT_RIGHT
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BoundingBox.
21
22
23
24
25
26
27
|
# File 'modules/boundingbox.rb', line 21
def initialize(points)
unless [0, 4, 8].include?(points.size)
raise ArgumentError, "Expected 0, 4 or 8 points (#{points.size} given)"
end
@points = points
end
|
Instance Attribute Details
#points ⇒ Object
17
18
19
|
# File 'modules/boundingbox.rb', line 17
def points
@points
end
|
Instance Method Details
#depth ⇒ Object
69
70
71
|
# File 'modules/boundingbox.rb', line 69
def depth
z_axis.length
end
|
#draw(view) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'modules/boundingbox.rb', line 97
def draw(view)
view.draw(GL_LINE_LOOP, @points[0..3])
if is_3d?
view.draw(GL_LINE_LOOP, @points[4..7])
connectors = [
@points[0], @points[4],
@points[1], @points[5],
@points[2], @points[6],
@points[3], @points[7],
]
view.draw(GL_LINES, connectors)
end
end
|
#empty? ⇒ Boolean
31
32
33
|
# File 'modules/boundingbox.rb', line 31
def empty?
@points.empty?
end
|
#have_area? ⇒ Boolean
48
49
50
|
# File 'modules/boundingbox.rb', line 48
def have_area? x_axis.valid? && y_axis.valid?
end
|
#have_volume? ⇒ Boolean
53
54
55
|
# File 'modules/boundingbox.rb', line 53
def have_volume? x_axis.valid? && y_axis.valid? && z_axis.valid?
end
|
#height ⇒ Object
64
65
66
|
# File 'modules/boundingbox.rb', line 64
def height
y_axis.length
end
|
#is_2d? ⇒ Boolean
37
38
39
|
# File 'modules/boundingbox.rb', line 37
def is_2d?
@points.size == 4
end
|
#is_3d? ⇒ Boolean
42
43
44
|
# File 'modules/boundingbox.rb', line 42
def is_3d?
@points.size == 8
end
|
#origin ⇒ Object
75
76
77
|
# File 'modules/boundingbox.rb', line 75
def origin
@points[BOTTOM_FRONT_LEFT]
end
|
#width ⇒ Object
59
60
61
|
# File 'modules/boundingbox.rb', line 59
def width
x_axis.length
end
|