Class: Geometry::Line
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
included
Instance Attribute Details
#options ⇒ Object
37
38
39
40
|
# File 'lib/geometry/line.rb', line 37
def options
@options = {} if !@options
@options
end
|
Class Method Details
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/geometry/line.rb', line 52
def self.[](*args)
if( 2 == args.size )
args.map! {|x| x.is_a?(Array) ? Point[*x] : x}
return TwoPointLine.new(*args) if args.all? {|x| x.is_a?(Vector)}
return PointSlopeLine.new(*args) if args.first.is_a?(Vector)
return SlopeInterceptLine.new(*args)
else
nil
end
end
|
.horizontal(y_intercept = 0) ⇒ Object
88
89
90
|
# File 'lib/geometry/line.rb', line 88
def self.horizontal(y_intercept=0)
SlopeInterceptLine.new(0, y_intercept)
end
|
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/geometry/line.rb', line 77
def self.new(options={})
from = options[:from] || options[:start]
to = options[:end] || options[:to]
if from and to
TwoPointLine.new(from, to)
else
raise ArgumentError, "Start and end Points must be provided"
end
end
|
.vertical(x_intercept = 0) ⇒ Object
91
92
93
|
# File 'lib/geometry/line.rb', line 91
def self.vertical(x_intercept=0)
SlopeInterceptLine.new(1/0.0, x_intercept)
end
|