class Geode::Line

Overview

The Line class represents a two-dimensional line with no defined endpoints. For a line with endpoints, see the Segment class.

Direct Known Subclasses

Defined in:

geode/line.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(slope : Number::Primitive, intercept_val : Number::Primitive) #

Creates a new Line.


[View source]

Class Method Detail

def self.perpendicular?(l1 : Line, l2 : Line) #

Returns whether the two given lines are perpendicular to each other.


[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 hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def horizontal? #

Returns whether the line is horizontal.


[View source]
def include?(other : Point) #

Returns whether the given point lies on the line.


[View source]
def slope : Float32 | Float64 | Int128 | Int16 | Int32 | Int64 | Int8 | UInt128 | UInt16 | UInt32 | UInt64 | UInt8 #

Returns the slope of the line.


[View source]
def to_s(io : IO) #

Returns a string representation of the line in slope-intercept form (y = mx + b). A vertical line will return a string in the form x = c where c is the line's x-intercept.


[View source]
def vertical? #

Returns whether the line is vertical.


[View source]
def x_intercept #

Returns the x-intercept of the line. If the line is horizontal, it has no x-intercept, so it returns nil.


[View source]
def y_intercept #

Returns the y-intercept of the line. If the line is vertical, it has no y-intercept, so it returns nil.


[View source]