In Files

  • typeprof-0.12.0/testbed/ao.rb

Class/Module Index [+]

Quicksearch

Vec

Attributes

x[RW]
y[RW]
z[RW]

Public Class Methods

new(x, y, z) click to toggle source

include Inline

 
               # File typeprof-0.12.0/testbed/ao.rb, line 15
def initialize(x, y, z)
  @x = x
  @y = y
  @z = z
end
            

Public Instance Methods

vadd(b) click to toggle source
 
               # File typeprof-0.12.0/testbed/ao.rb, line 23
def vadd(b)
  Vec.new(@x + b.x, @y + b.y, @z + b.z)
end
            
vcross(b) click to toggle source

make_inline_method :vsub

 
               # File typeprof-0.12.0/testbed/ao.rb, line 32
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

make_inline_method :vcross

 
               # File typeprof-0.12.0/testbed/ao.rb, line 39
def vdot(b)
  r = @x * b.x + @y * b.y + @z * b.z
  r
end
            
vlength() click to toggle source

make_inline_method :vdot

 
               # File typeprof-0.12.0/testbed/ao.rb, line 45
def vlength
  Math.sqrt(@x * @x + @y * @y + @z * @z)
end
            
vnormalize() click to toggle source

make_inline_method :vlength

 
               # File typeprof-0.12.0/testbed/ao.rb, line 50
def vnormalize
  len = vlength
  v = Vec.new(@x, @y, @z)
  if len > 1.0e-17
    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 typeprof-0.12.0/testbed/ao.rb, line 27
def vsub(b)
  Vec.new(@x - b.x, @y - b.y, @z - b.z)
end