class RubyGL::Vec4
Public Class Methods
new()
click to toggle source
# File lib/rubygl/math.rb, line 105 def initialize() @data = Array.new(4, 0) end
Public Instance Methods
+(other_vector)
click to toggle source
# File lib/rubygl/math.rb, line 109 def +(other_vector) new_vector = Vec4.new() for i in 0..@data.size new_vector[i] = @data[i] + other_vector[i] end new_vector end
-(other_vector)
click to toggle source
# File lib/rubygl/math.rb, line 119 def -(other_vector) new_vector = Vec4.new() for i in 0..@data.size new_vector[i] = @data[i] - other_vector[i] end new_vector end
[](index)
click to toggle source
# File lib/rubygl/math.rb, line 158 def [](index) @data[index] end
[]=(index, value)
click to toggle source
# File lib/rubygl/math.rb, line 162 def []=(index, value) @data[index] = value end
len()
click to toggle source
# File lib/rubygl/math.rb, line 148 def len() sum = 0 for i in 0...@data.size sum += @data[i] * @data[i] end Math::sqrt(sum) end
norm()
click to toggle source
# File lib/rubygl/math.rb, line 137 def norm() new_vector = Vec2.new() for i in 0...@data.size new_vector[i] = @data[i] end new_vector.norm! new_vector end
norm!()
click to toggle source
# File lib/rubygl/math.rb, line 129 def norm!() curr_len = self.len() for i in 0...@data.size @data /= curr_len end end
to_a()
click to toggle source
# File lib/rubygl/math.rb, line 170 def to_a() self.to_ary end
to_ary()
click to toggle source
# File lib/rubygl/math.rb, line 166 def to_ary() Array.new(@data) end