Class: Line
- Inherits:
-
Object
- Object
- Line
- Defined in:
- lib/line.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
Instance Method Summary collapse
-
#initialize(p1, p2) ⇒ Line
constructor
A new instance of Line.
- #intersect(other) ⇒ Object
Constructor Details
#initialize(p1, p2) ⇒ Line
Returns a new instance of Line.
2 3 4 5 6 |
# File 'lib/line.rb', line 2 def initialize(p1, p2) @a = 1.0*(p2.y-p1.y)/(p2.x-p1.x) @b = 1.0*p1.y - @a*p1.x # pp [p1, p2, @a, @b] end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
15 16 17 |
# File 'lib/line.rb', line 15 def a @a end |
#b ⇒ Object
Returns the value of attribute b.
15 16 17 |
# File 'lib/line.rb', line 15 def b @b end |