Class: Sevgi::Geometry::Line
- Inherits:
-
LineBase
- Object
- Sevgi::Geometry::Line
- Extended by:
- Forwardable
- Defined in:
- lib/sevgi/geometry/elements/line.rb,
lib/sevgi/geometry/equation.rb
Overview
Open lined element with one segment.
Class Method Summary collapse
-
.[](length, angle, position: Origin) ⇒ Sevgi::Geometry::Line
Builds a line from length and angle.
-
.from_length_angle(length, angle, position: Origin) ⇒ Sevgi::Geometry::Line
Builds a line from length and angle.
-
.from_points(starting, ending) ⇒ Sevgi::Geometry::Line
Builds a line from two endpoints.
Instance Method Summary collapse
-
#draw!(node) ⇒ Object
Draws the line into a graphics node.
-
#equation ⇒ Sevgi::Geometry::Equation::Linear
Returns the linear equation containing this line.
-
#over?(point) ⇒ Boolean
Reports whether a point lies on the finite line segment.
-
#shift(distance) ⇒ Sevgi::Geometry::Line
Returns a parallel line shifted by a signed perpendicular offset.
Class Method Details
.[](length, angle, position: Origin) ⇒ Sevgi::Geometry::Line
21 |
# File 'lib/sevgi/geometry/elements/line.rb', line 21 def self.[](...) = from_length_angle(...) |
.from_length_angle(length, angle, position: Origin) ⇒ Sevgi::Geometry::Line
Builds a line from length and angle.
29 |
# File 'lib/sevgi/geometry/elements/line.rb', line 29 def self.from_length_angle(length, angle, position: Origin) = new_by_segments(Segment[length, angle], position:) |
.from_points(starting, ending) ⇒ Sevgi::Geometry::Line
37 |
# File 'lib/sevgi/geometry/elements/line.rb', line 37 def self.from_points(...) = new_by_points(...) |
Instance Method Details
#draw!(node) ⇒ Object
Draws the line into a graphics node.
51 |
# File 'lib/sevgi/geometry/elements/line.rb', line 51 def draw!(node, **) = node.LineTo(x1: position.x, y1: position.y, x2: ending.x, y2: ending.y, **) |
#equation ⇒ Sevgi::Geometry::Equation::Linear
Returns the linear equation containing this line.
105 |
# File 'lib/sevgi/geometry/equation.rb', line 105 def equation = position.equation(angle) |
#over?(point) ⇒ Boolean
Reports whether a point lies on the finite line segment.
57 58 59 60 61 |
# File 'lib/sevgi/geometry/elements/line.rb', line 57 def over?(point) point = Tuple[Point, point] within_range?(point) && equation.on?(point) end |
#shift(distance) ⇒ Sevgi::Geometry::Line
Returns a parallel line shifted by a signed perpendicular offset.
66 |
# File 'lib/sevgi/geometry/elements/line.rb', line 66 def shift(distance) = translate(distance * F.sin(angle), -distance * F.cos(angle)) |