Class: Geom3d::Line

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p1, p2) ⇒ Line

Returns a new instance of Line.



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

def initialize p1, p2
  @p1 = Point.new(p1)
  @p2 = Point.new(p2)
end

Instance Attribute Details

#p1Object (readonly)

Returns the value of attribute p1.



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

def p1
  @p1
end

#p2Object (readonly)

Returns the value of attribute p2.



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

def p2
  @p2
end

Instance Method Details

#pos(t) ⇒ Object



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

def pos t
  @p1 + t * (@p2 - @p1)
end

#to_sObject



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

def to_s
  "Line(#{@p1.to_s}, #{@p2.to_s})"
end