class GeoTriangleExt::LinearFunction

Attributes

ax[W]
ay[W]
bx[W]
by[W]

Public Class Methods

create(ax, ay, bx, by) click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 10
def create(ax, ay, bx, by)
  lf = self.new
  lf.ax = ax
  lf.ay = ay
  lf.bx = bx
  lf.by = by
  lf
end

Public Instance Methods

ax() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 21
def ax
  @bax ||= BigDecimal(@ax.to_s)
  @bax

end
ay() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 27
def ay
  @bay ||= BigDecimal(@ay.to_s)
  @bay
end
bx() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 32
def bx
  @bbx ||= BigDecimal(@bx.to_s)
  @bbx
end
by() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 37
def by
  @bby ||= BigDecimal(@by.to_s)
  @bby
end
intercept() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 59
def intercept
  return unless valid?
  (ax * by - ay * bx) / (ax - bx)
end
middle_point() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 48
def middle_point
  x = (ax + bx) / 2.0
  y = (ay + by) / 2.0
  [x, y]
end
orthogonal_intercept() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 69
def orthogonal_intercept
  return unless valid?
  (ax*ax + ay*ay - bx*bx - by*by) / (2 * (ay - by))
end
orthogonal_slope() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 64
def orthogonal_slope
  return unless valid?
  (bx - ax) / (ay - by)
end
slope() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 54
def slope
  return unless valid?
  (ay - by) / (ax - bx)
end
valid?() click to toggle source
# File lib/geo_triangle_ext/linear_function.rb, line 42
def valid?
  return false if ax == bx
  return false if ay == by
  true
end