Class: Cosmos::GlBounds

Inherits:
Object show all
Defined in:
lib/cosmos/gui/opengl/gl_bounds.rb

Instance Method Summary collapse

Constructor Details

#initialize(x0, x1, y0, y1, z0, z1) ⇒ GlBounds

Returns a new instance of GlBounds.



14
15
16
17
18
19
20
21
# File 'lib/cosmos/gui/opengl/gl_bounds.rb', line 14

def initialize (x0, x1, y0, y1, z0, z1)
  @x0 = x0
  @x1 = x1
  @y0 = y0
  @y1 = y1
  @z0 = z0
  @z1 = z1
end

Instance Method Details

#[](index) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cosmos/gui/opengl/gl_bounds.rb', line 23

def [] (index)
  case index
  when 0
    @x0
  when 1
    @x1
  when 2
    @y0
  when 3
    @y1
  when 4
    @z0
  when 5
    @z1
  else
    nil
  end
end

#centerObject



42
43
44
# File 'lib/cosmos/gui/opengl/gl_bounds.rb', line 42

def center
  [(@x0 + @x1) / 2.0, (@y0 + @y1) / 2.0, (@z0 + @z1) / 2.0]
end

#longestObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cosmos/gui/opengl/gl_bounds.rb', line 46

def longest
  x = @x1 - @x0
  y = @y1 - @y0
  z = @z1 - @z0
  if x > y
    if x > z
      x
    else
      z
    end
  else
    if y > z
      y
    else
      z
    end
  end
end