Class: Sevgi::Geometry::Polyline

Inherits:
PolylineBase
  • Object
show all
Defined in:
lib/sevgi/geometry/elements/polyline.rb

Overview

Variable-size open lined element with at least two points.

Examples:

Pair mathematical notation with English conveniences

Sevgi::Geometry::Polyline[[2, 0], [1, 90]] == Sevgi::Geometry::Polyline.from_segments([2, 0], [1, 90])
Sevgi::Geometry::Polyline.([0, 0], [2, 0]) == Sevgi::Geometry::Polyline.from_points([0, 0], [2, 0])

Measure and query an open path

path = Sevgi::Geometry::Polyline.([0, 0], [3, 0], [3, 4])
path.length         # => 7.0
path.on?([2, 0])    # => true
path.inside?([1, 1]) # => false

Class Method Summary collapse

Class Method Details

.[](*segments, position: Origin) ⇒ Sevgi::Geometry::Polyline

Builds a polyline from ordered segments.

Parameters:

Returns:

Raises:



41
42
43
44
45
46
47
# File 'lib/sevgi/geometry/elements/polyline.rb', line 41

class Polyline < PolylineBase
  private

  def validate_geometry!
    Error.("Polyline requires at least two points") if points.size < 2
  end
end

.call(*points) ⇒ Sevgi::Geometry::Polyline

Builds a polyline from ordered points.

Parameters:

Returns:

Raises:



41
42
43
44
45
46
47
# File 'lib/sevgi/geometry/elements/polyline.rb', line 41

class Polyline < PolylineBase
  private

  def validate_geometry!
    Error.("Polyline requires at least two points") if points.size < 2
  end
end

.from_points(*points) ⇒ Sevgi::Geometry::Polyline

Builds a polyline from ordered points.

Parameters:

Returns:

Raises:



41
42
43
44
45
46
47
# File 'lib/sevgi/geometry/elements/polyline.rb', line 41

class Polyline < PolylineBase
  private

  def validate_geometry!
    Error.("Polyline requires at least two points") if points.size < 2
  end
end

.from_segments(*segments, position: Origin) ⇒ Sevgi::Geometry::Polyline

Builds a polyline from ordered segments.

Parameters:

Returns:

Raises:



41
42
43
44
45
46
47
# File 'lib/sevgi/geometry/elements/polyline.rb', line 41

class Polyline < PolylineBase
  private

  def validate_geometry!
    Error.("Polyline requires at least two points") if points.size < 2
  end
end