Class: IRB::Vec (Ruby 2.7.5)
Description: Class : IRB::Vec - Ruby 2.7.5

### Home Classes Methods

### In Files

- irb/easter-egg.rb

### Parent

Object

### Methods

- ::new
- #cross
- #dot
- #normalize
- #sub

### Class/Module Index

Quicksearch

- Binding
- IRB::Abort
- IRB::Canvas
- IRB::Color
- IRB::Color::SymbolState
- IRB::Context
- IRB::ContextExtender
- IRB::ExtendCommandBundle
- IRB::FileInputMethod
- IRB::Frame
- IRB::Frame::FrameOverflow
- IRB::Frame::FrameUnderflow
- IRB::History
- IRB::InputMethod
- IRB::Inspector
- IRB::Irb
- IRB::IrbLoader
- IRB::JobManager
- IRB::LoadAbort
- IRB::MethodExtender
- IRB::Notifier
- IRB::Notifier::AbstractNotifier
- IRB::Notifier::CompositeNotifier
- IRB::Notifier::ErrUndefinedNotifier
- IRB::Notifier::ErrUnrecognizedLevel
- IRB::Notifier::LeveledNotifier
- IRB::Notifier::NoMsgNotifier
- IRB::OutputMethod
- IRB::OutputMethod::NotImplementedError
- IRB::ReadlineInputMethod
- IRB::ReidlineInputMethod
- IRB::RubyModel
- IRB::StdioInputMethod
- IRB::StdioOutputMethod
- IRB::Vec
- IRB::WorkSpace
- Object
- XMP
- XMP::StringInputMethod

No matching classes.

# IRB::Vec

### Attributes

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

### Public Class Methods

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

                   # File irb/easter-egg.rb, line 6
    def initialize(x, y, z)
      @x, @y, @z = x, y, z
    end

### Public Instance Methods

cross(other) click to toggle source

                   # File 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) click to toggle source

                   # File irb/easter-egg.rb, line 16
    def dot(other)
      @x*other.x + @y*other.y + @z*other.z
    end

normalize() click to toggle source

                   # File 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) click to toggle source

                   # File irb/easter-egg.rb, line 12
    def sub(other)
      Vec.new(@x - other.x, @y - other.y, @z - other.z)
    end