Class: Sevgi::Geometry::Equation::Line::Vertical
- Inherits:
-
Object
- Object
- Sevgi::Geometry::Equation::Line::Vertical
- Defined in:
- lib/sevgi/geometry/equation/line/vertical.rb
Instance Method Summary collapse
-
#initialize(c) ⇒ Vertical
constructor
A new instance of Vertical.
- #intersection(other) ⇒ Object
- #left?(point) ⇒ Boolean
- #onto?(point) ⇒ Boolean
- #right?(point) ⇒ Boolean
- #shift(distance = nil, dx: nil, dy: nil) ⇒ Object
- #to_s ⇒ Object
- #x(_ = nil) ⇒ Object
- #y(_ = nil) ⇒ Object
Constructor Details
#initialize(c) ⇒ Vertical
Returns a new instance of Vertical.
8 9 10 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 8 def initialize(c) @x = c end |
Instance Method Details
#intersection(other) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 12 def intersection(other) case other when Diagonal, Horizontal then x, y = self.x, other.y(self.x) when Vertical then x, y = ::Float::INFINITY, ::Float::INFINITY end Point[x, y] end |
#left?(point) ⇒ Boolean
21 22 23 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 21 def left?(point) F.lt?(point.x, x(point.y)) end |
#onto?(point) ⇒ Boolean
25 26 27 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 25 def onto?(point) F.eq?(point.x, x(point.y)) end |
#right?(point) ⇒ Boolean
29 30 31 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 29 def right?(point) F.gt?(point.x, x(point.y)) end |
#shift(distance = nil, dx: nil, dy: nil) ⇒ Object
33 34 35 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 33 def shift(distance = nil, dx: nil, dy: nil) self.class.new(x + (distance || 0.0) + (dx || 0.0)) end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 37 def to_s "L<x = #{F.approx(x)}>" end |
#x(_ = nil) ⇒ Object
41 42 43 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 41 def x(_ = nil) @x end |
#y(_ = nil) ⇒ Object
45 46 47 |
# File 'lib/sevgi/geometry/equation/line/vertical.rb', line 45 def y(_ = nil) ::Float::INFINITY end |