Class: Geometry::TwoPointLine
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
Accessors collapse
-
#slope ⇒ Object
!@attribute [r[ slope @return [Number] the slope of the Line.
Instance Method Summary collapse
-
#initialize(point0, point1) ⇒ TwoPointLine
constructor
A new instance of TwoPointLine.
- #inspect ⇒ Object (also: #to_s)
Methods inherited from Line
[], horizontal, new, vertical
Methods included from ClusterFactory
Constructor Details
#initialize(point0, point1) ⇒ TwoPointLine
Returns a new instance of TwoPointLine.
137 138 139 |
# File 'lib/aurora-geometry/line.rb', line 137 def initialize(point0, point1) @first, @last = [Point[point0], Point[point1]] end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
135 136 137 |
# File 'lib/aurora-geometry/line.rb', line 135 def first @first end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
135 136 137 |
# File 'lib/aurora-geometry/line.rb', line 135 def last @last end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
140 141 142 |
# File 'lib/aurora-geometry/line.rb', line 140 def inspect 'Line(' + @first.inspect + ', ' + @last.inspect + ')' end |
#slope ⇒ Object
!@attribute [r[ slope
@return [Number] the slope of the {Line}
148 149 150 |
# File 'lib/aurora-geometry/line.rb', line 148 def slope (last.y - first.y)/(last.x - first.x) end |