class Geode::Segment

Overview

The Segment class represents a two-dimensional line segment with two endpoints.

Included Modules

Defined in:

geode/line.cr

Constructors

Instance Method Summary

Instance methods inherited from class Geode::Line

==(other : self) ==, hash(hasher) hash, horizontal? horizontal?, include?(other : Point) include?, slope : Float32 | Float64 | Int128 | Int16 | Int32 | Int64 | Int8 | UInt128 | UInt16 | UInt32 | UInt64 | UInt8 slope, to_s(io : IO) to_s, vertical? vertical?, x_intercept x_intercept, y_intercept y_intercept

Constructor methods inherited from class Geode::Line

new(slope : Number::Primitive, intercept_val : Number::Primitive) new

Class methods inherited from class Geode::Line

perpendicular?(l1 : Line, l2 : Line) perpendicular?

Constructor Detail

def self.new(p1 : Point, p2 : Point) #

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def each(&) #

Separately yields the two endpoints of the segment.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def include?(other : Point) #

Returns whether the given point lies on the segment.


[View source]
def length #

Returns the length of the segment.


[View source]
def midpoint #

Returns the midpoint of the segment.


[View source]
def p1 : Geode::Point #

Returns the first endpoint of the segment.


[View source]
def p2 : Geode::Point #

Returns the second endpoint of the segment.


[View source]
def slope #

Returns the slope of the segment.


[View source]
def to_line #

Returns a Line representation of the segment.


[View source]