Class: Sevgi::Geometry::Element::Arced

Inherits:
Sevgi::Geometry::Element show all
Defined in:
lib/sevgi/geometry/element.rb

Overview

Abstract family of circular and elliptical boundary elements. Arc is open, while Ellipse and Circle have closed boundaries. Concrete values share exact and precision-aware comparisons.

Direct Known Subclasses

Arc, Sevgi::Geometry::Ellipse

Instance Method Summary collapse

Methods inherited from Sevgi::Geometry::Element

#at, #box, #closed?, #equations, #ignorable?, #intersection, lined, #position, #translate

Instance Method Details

#eq?(other, precision: nil) ⇒ Boolean

Compares canonical fields with coordinate and numeric precision.

Parameters:

  • other (Object) —

    comparison target

  • precision (Integer, nil) (defaults to: nil) —

    decimal precision, or nil for the current function default

Returns:

  • (Boolean)


635
636
637
638
639
640
# File 'lib/sevgi/geometry/element.rb', line 635

def eq?(other, precision: nil)
  other.instance_of?(self.class) &&
    state.zip(other.send(:state)).all? do |left, right|
      left.is_a?(::Numeric) ? F.eq?(left, right, precision:) : left.eq?(right, precision:)
    end
end

#eql?(other) ⇒ Boolean Also known as: ==

Reports strict equality by concrete class and canonical fields.

Parameters:

  • other (Object) —

    comparison target

Returns:

  • (Boolean)


645
# File 'lib/sevgi/geometry/element.rb', line 645

def eql?(other) = other.instance_of?(self.class) && state == other.send(:state)

#hash ⇒ Integer

Returns a hash independent of numeric precision.

Returns:

  • (Integer)


649
# File 'lib/sevgi/geometry/element.rb', line 649

def hash = [self.class, *state].hash

#outside?(point) ⇒ Boolean

Reports whether a point is outside the element.

Parameters:

Returns:

  • (Boolean)

Raises:



655
# File 'lib/sevgi/geometry/element.rb', line 655

def outside?(point) = !inside?(point)