类 IRB::Vec

属性

x[R]
y[R]
z[R]

公共类方法

new(x, y, z) 点击切换源代码
# File lib/irb/easter-egg.rb, line 6
def initialize(x, y, z)
  @x, @y, @z = x, y, z
end

公共实例方法

cross(other) 点击切换源代码
# File lib/irb/easter-egg.rb, line 20
def cross(other)
  ox, oy, oz = other.x, other.y, other.z
  Vec.new(@y*oz-@z*oy, @z*ox-@x*oz, @x*oy-@y*ox)
end
dot(other) 点击切换源代码
# File lib/irb/easter-egg.rb, line 16
def dot(other)
  @x*other.x + @y*other.y + @z*other.z
end
normalize() 点击切换源代码
# File lib/irb/easter-egg.rb, line 25
def normalize
  r = Math.sqrt(self.dot(self))
  Vec.new(@x / r, @y / r, @z / r)
end
sub(other) 点击切换源代码
# File lib/irb/easter-egg.rb, line 12
def sub(other)
  Vec.new(@x - other.x, @y - other.y, @z - other.z)
end