Class: Sevgi::Geometry::Triangle

Inherits:
TriangleBase
  • Object
show all
Defined in:
lib/sevgi/geometry/elements/triangle.rb

Overview

Closed three-sided element built from two non-collinear adjacent segments.

Class Method Summary collapse

Class Method Details

.[](segment_a, segment_b, position: Origin) ⇒ Sevgi::Geometry::Triangle

Builds a triangle from two adjacent segments.

The closing segment is the direct vector from the end of segment_b back to position. Segment order controls orientation; reversing the inputs returns the corresponding opposite orientation. Zero-length or collinear inputs are rejected using the current numeric precision.

Parameters:

Returns:

Raises:



23
24
25
26
27
28
# File 'lib/sevgi/geometry/elements/triangle.rb', line 23

def self.[](segment_a, segment_b, position: Origin)
  a, b = Tuples[Segment, segment_a, segment_b]

  validate!(a, b)
  new_by_segments(a, b, closing_segment(a, b), position:)
end