Skip to content

Implement LineSegment #9

@callmekeypuncher

Description

@callmekeypuncher

Description

Polygon has to store the information of it`s points position. But in our case it isn`t enough. For example, if the result of a boolean operation is a nonconvex polygon, we will be unable to reconstruct the polygon`s shape correctly because we don`t know how the points are connected to each other.

Proposed solution

We can use line segment to store relation between points. The line segment can be represented by two points - the beginning and the ending of a segment.

require_relative 'elementary/point'

class LineSegment
  attr_reader :begins_at
  attr_reader :ends_at

  # Your implementation goes here...
end

line_segment = LineSegment.new(Point.new(1.0, 2.0), Point.new(3.0, 4.0))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions