Class: Geom3d::Ray

Inherits:
Object
  • Object
show all
Defined in:
lib/geom3d/ray.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start, dir) ⇒ Ray

Returns a new instance of Ray.



8
9
10
11
# File 'lib/geom3d/ray.rb', line 8

def initialize start, dir
  @start = Point.new(start)
  @dir = Vector.new(dir).norm
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



6
7
8
# File 'lib/geom3d/ray.rb', line 6

def dir
  @dir
end

#startObject (readonly)

Returns the value of attribute start.



6
7
8
# File 'lib/geom3d/ray.rb', line 6

def start
  @start
end

Instance Method Details

#pos(t) ⇒ Object



13
14
15
# File 'lib/geom3d/ray.rb', line 13

def pos t
  @start + t * @dir
end

#to_sObject



17
18
19
# File 'lib/geom3d/ray.rb', line 17

def to_s
  "Ray(#{@start.to_s},#{@dir.to_s}"
end