In Files

  • benchmark/bm_ao_render.rb

Vec

Public Class Methods

new(x, y, z) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 32
def initialize(x, y, z)
  @x = x
  @y = y
  @z = z
end
            

Public Instance Methods

vadd(b) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 45
def vadd(b)
  Vec.new(@x + b.x, @y + b.y, @z + b.z)
end
            
vcross(b) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 53
def vcross(b)
  Vec.new(@y * b.z - @z * b.y,
          @z * b.x - @x * b.z,
          @x * b.y - @y * b.x)
end
            
vdot(b) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 59
def vdot(b)
  r = @x * b.x + @y * b.y + @z * b.z
  r
end
            
vlength() click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 64
def vlength
  Math.sqrt(@x * @x + @y * @y + @z * @z)
end
            
vnormalize() click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 68
def vnormalize
  len = vlength
  v = Vec.new(@x, @y, @z)
  if len > 1.0e-17 then
    v.x = v.x / len
    v.y = v.y / len
    v.z = v.z / len
  end
  v
end
            
vsub(b) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 49
def vsub(b)
  Vec.new(@x - b.x, @y - b.y, @z - b.z)
end
            
x() click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 41
def x; @x; end
            
x=(v) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 38
def x=(v); @x = v; end
            
y() click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 42
def y; @y; end
            
y=(v) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 39
def y=(v); @y = v; end
            
z() click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 43
def z; @z; end
            
z=(v) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 40
def z=(v); @z = v; end