Module: Sevgi::Geometry

Defined in:
lib/sevgi/geometry.rb,
lib/sevgi/geometry/point.rb,
lib/sevgi/geometry/errors.rb,
lib/sevgi/geometry/element.rb,
lib/sevgi/geometry/segment.rb,
lib/sevgi/geometry/version.rb,
lib/sevgi/geometry/equation.rb,
lib/sevgi/geometry/internal.rb,
lib/sevgi/geometry/operation.rb,
lib/sevgi/geometry/elements/line.rb,
lib/sevgi/geometry/elements/rect.rb,
lib/sevgi/geometry/equation/linear.rb,
lib/sevgi/geometry/operation/align.rb,
lib/sevgi/geometry/operation/sweep.rb,
lib/sevgi/geometry/elements/polygon.rb,
lib/sevgi/geometry/elements/polyline.rb,
lib/sevgi/geometry/elements/triangle.rb,
lib/sevgi/geometry/equation/quadratic.rb,
lib/sevgi/geometry/elements/parallelogram.rb

Overview

Immutable screen-space geometry values used by Sevgi layout and drawing helpers.

Coordinates follow SVG screen conventions: +x points right, +y points down, and positive angles turn clockwise. Constructors accept Point and Segment objects or their two-number Array forms. Transformations return new values; they do not mutate their receiver.

Shape constructors have two complementary notations: Shape[...] accepts dimensions or segments, while Shape.(...) accepts points. Named factories such as Rect.from_size and Rect.from_corners expose the same distinction when a call site benefits from spelling it out.

Trigonometric construction can retain ordinary floating-point noise. Use approx for presentation values and eq? for precision-aware comparison; strict == intentionally compares the exact immutable value.

Examples:

Measure and move a line

line = Sevgi::Geometry::Line.([0, 0], [3, 4])
line.length                    #=> 5.0
line.translate(2, 1).starting #=> Point[2.0, 1.0]

Follow SVG screen directions

origin = Sevgi::Geometry::Point.origin
Sevgi::Geometry::Point.angle(origin, [0, 10]) #=> 90.0
origin.translate(0, 10).below?(origin)        #=> true

See Also:

Defined Under Namespace

Modules: Operation Classes: Element, Equation, LengthAngle, Line, Parallelogram, Point, Polygon, Polyline, Rect, Segment, Square, Triangle

Constant Summary collapse

Origin =

Origin point in SVG/screen coordinates.

Point.origin
Error =

Base error for geometry input and operation failures.

Class.new(Error)
VERSION =

Component version.

"0.98.2"