Module: Sevgi::Geometry::Operation

Extended by:
Operation
Included in:
Operation
Defined in:
lib/sevgi/geometry/operation.rb,
lib/sevgi/geometry/operation/align.rb,
lib/sevgi/geometry/operation/sweep.rb

Overview

Dispatches geometry operations to operation handler modules.

Constant Summary collapse

OperationError =

Raised when an operation starts but cannot complete.

Class.new(Error)
OperationInapplicableError =

Raised when an operation does not apply to the target element.

Class.new(Error)

Class Method Summary collapse

Class Method Details

.align(element, other, alignment = :center) ⇒ Sevgi::Geometry::Element

Returns an element translated to align with another element.

Parameters:

Returns:

Raises:



80
# File 'lib/sevgi/geometry/operation.rb', line 80

def register(handler, *operations) = operations.each { |operation| def_operation(operation, handler) }

.alignment(element, other, alignment = :center) ⇒ Sevgi::Geometry::Point

Returns the offset needed to align one element with another.

Parameters:

Returns:

Raises:



80
# File 'lib/sevgi/geometry/operation.rb', line 80

def register(handler, *operations) = operations.each { |operation| def_operation(operation, handler) }

.sweep(element, initial:, angle:, step:, limit: Sweep::LIMIT) {|lines| ... } ⇒ Array<Sevgi::Geometry::Line>

Sweeps parallel lines across a lined element in both directions.

Parameters:

  • element (Sevgi::Geometry::Element::Lined)

    element to intersect

  • initial (Sevgi::Geometry::Point, Array<Numeric>)

    point on the initial sweep line

  • angle (Numeric)

    clockwise sweep line angle in degrees

  • step (Numeric)

    signed distance between sweep lines

  • limit (Integer) (defaults to: Sweep::LIMIT)

    maximum iterations per direction

Yields:

  • (lines)

    optional hook receiving the generated lines

Yield Parameters:

Yield Returns:

  • (void)

Returns:

Raises:



80
# File 'lib/sevgi/geometry/operation.rb', line 80

def register(handler, *operations) = operations.each { |operation| def_operation(operation, handler) }

.sweep!(element, initial:, angle:, step:, limit: Sweep::LIMIT) {|lines| ... } ⇒ Array<Sevgi::Geometry::Line>

Sweeps parallel lines across a lined element and requires at least one result.

Parameters:

  • element (Sevgi::Geometry::Element::Lined)

    element to intersect

  • initial (Sevgi::Geometry::Point, Array<Numeric>)

    point on the initial sweep line

  • angle (Numeric)

    clockwise sweep line angle in degrees

  • step (Numeric)

    signed distance between sweep lines

  • limit (Integer) (defaults to: Sweep::LIMIT)

    maximum iterations per direction

Yields:

  • (lines)

    optional hook receiving the generated lines

Yield Parameters:

Yield Returns:

  • (void)

Returns:

Raises:



80
# File 'lib/sevgi/geometry/operation.rb', line 80

def register(handler, *operations) = operations.each { |operation| def_operation(operation, handler) }

.unisweep(element, equation, step, limit: Sweep::LIMIT) ⇒ Array<Sevgi::Geometry::Line>

Sweeps parallel lines in one signed direction from an equation.

Parameters:

Returns:

Raises:



80
# File 'lib/sevgi/geometry/operation.rb', line 80

def register(handler, *operations) = operations.each { |operation| def_operation(operation, handler) }