Class: Sevgi::Geometry::Equation
- Inherits:
-
Object
- Object
- Sevgi::Geometry::Equation
show all
- Defined in:
- lib/sevgi/geometry/equation.rb,
lib/sevgi/geometry/equation/linear.rb,
lib/sevgi/geometry/equation/quadratic.rb
Defined Under Namespace
Classes: Linear, Quadratic
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.diagonal(slope:, intercept:) ⇒ Object
6
|
# File 'lib/sevgi/geometry/equation.rb', line 6
def self.diagonal(slope:, intercept:) = Linear::Diagonal.new(slope:, intercept:)
|
.horizontal(const) ⇒ Object
8
|
# File 'lib/sevgi/geometry/equation.rb', line 8
def self.horizontal(const) = Linear::Horizontal.new(const)
|
.vertical(const) ⇒ Object
10
|
# File 'lib/sevgi/geometry/equation.rb', line 10
def self.vertical(const) = Linear::Vertical.new(const)
|
Instance Method Details
#intersect(other) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/sevgi/geometry/equation.rb', line 12
def intersect(other)
Error.("Must be an equation: #{other}") unless other.is_a?(Equation)
points = case [self, other]
in [Linear, Linear]
linear_vs_linear(other)
in [Linear, Quadratic]
linear_vs_quadratic(other)
in [Quadratic, Quadratic]
quadratic_vs_quadratic(other)
else
Error.("TODO")
end
Array(points)
end
|
#y(_x) ⇒ Object
29
|
# File 'lib/sevgi/geometry/equation.rb', line 29
def y(_x, ...) = raise NoMethodError, "#{self.class}#y must be implemented"
|