vadd(b)
            click to toggle source
          
          
          
  
            
            
            
            
            
               
               
def vadd(b)
  Vec.new(@x + b.x, @y + b.y, @z + b.z)
end
             
             
            
           
          
          
         
      
        
          
          
          
            vcross(b)
            click to toggle source
          
          
          
  
            
            
            
            
            
               
               
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
          
          
          
  
            
            
            
            
            
               
               
def vdot(b)
  r = @x * b.x + @y * b.y + @z * b.z
  r
end
             
             
            
           
          
          
         
      
        
          
          
          
            vlength()
            click to toggle source
          
          
          
  
            
            
            
            
            
               
               
def vlength
  Math.sqrt(@x * @x + @y * @y + @z * @z)
end
             
             
            
           
          
          
         
      
        
          
          
          
            vnormalize()
            click to toggle source
          
          
          
  
            
            
            
            
            
               
               
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
          
          
          
  
            
            
            
            
            
               
               
def vsub(b)
  Vec.new(@x - b.x, @y - b.y, @z - b.z)
end
             
             
            
           
          
          
         
      
        
          
          
          
            x()
            click to toggle source
          
          
          
          
          
         
      
        
          
          
          
            x=(v)
            click to toggle source
          
          
          
          
          
         
      
        
          
          
          
            y()
            click to toggle source
          
          
          
          
          
         
      
        
          
          
          
            y=(v)
            click to toggle source
          
          
          
          
          
         
      
        
          
          
          
            z()
            click to toggle source
          
          
          
          
          
         
      
        
          
          
          
            z=(v)
            click to toggle source