module Dieses::Geometry::Equation
Public Instance Methods
from_line(line)
click to toggle source
# File lib/dieses/geometry/equation.rb, line 11 def from_line(line) starting, ending = line.starting, line.ending if (c = starting.x) == ending.x vertical(c) elsif (c = starting.y) == ending.y horizontal(c) else slope = (ending.y - starting.y) / (ending.x - starting.x) intercept = starting.y - slope * starting.x slant(slope: slope, intercept: intercept) end end
horizontal(c)
click to toggle source
# File lib/dieses/geometry/equation.rb, line 48 def horizontal(c) slant(slope: 0.0, intercept: c) end
intersect(u, v)
click to toggle source
# File lib/dieses/geometry/equation.rb, line 52 def intersect(u, v) u.intersect(v) end
slant(slope:, intercept:)
click to toggle source
# File lib/dieses/geometry/equation.rb, line 26 def slant(slope:, intercept:) Slant.new slope: slope, intercept: intercept end
slant_from_direction(point:, angle:)
click to toggle source
# File lib/dieses/geometry/equation.rb, line 30 def slant_from_direction(point:, angle:) return horizontal(point.y) if (angle % 180).zero? return vertical(point.x) if (angle % 90).zero? slope = Math.tan(Support.to_radian(angle.to_f)) intercept = point.y - slope * point.x slant(slope: slope, intercept: intercept) end
steep(c)
click to toggle source
# File lib/dieses/geometry/equation.rb, line 40 def steep(c) Steep.new c end