Class: Geometry::Arc
- Inherits:
-
Object
- Object
- Geometry::Arc
- Includes:
- ClusterFactory
- Defined in:
- lib/geometry/arc.rb
Overview
Direct Known Subclasses
Instance Attribute Summary collapse
-
#center ⇒ Object
readonly
Returns the value of attribute center.
-
#end_angle ⇒ Number
readonly
The ending angle of the Arc as radians from the x-axis.
-
#radius ⇒ Number
readonly
The radius of the Arc.
-
#start_angle ⇒ Number
readonly
The starting angle of the Arc as radians from the x-axis.
Class Method Summary collapse
Instance Method Summary collapse
-
#first ⇒ Point
The starting point of the Arc.
-
#initialize(center, radius, start_angle, end_angle) ⇒ Arc
constructor
Construct a new Arc.
-
#last ⇒ Point
The end point of the Arc.
Methods included from ClusterFactory
Constructor Details
#initialize(center, radius, start_angle, end_angle) ⇒ Arc
Construct a new Geometry::Arc
59 60 61 62 63 64 |
# File 'lib/geometry/arc.rb', line 59 def initialize(center, radius, start_angle, end_angle) @center = Point[center] @radius = radius @start_angle = start_angle @end_angle = end_angle end |
Instance Attribute Details
#center ⇒ Object (readonly)
Returns the value of attribute center.
19 20 21 |
# File 'lib/geometry/arc.rb', line 19 def center @center end |
#end_angle ⇒ Number (readonly)
Returns the ending angle of the Geometry::Arc as radians from the x-axis.
28 29 30 |
# File 'lib/geometry/arc.rb', line 28 def end_angle @end_angle end |
#radius ⇒ Number (readonly)
Returns the radius of the Geometry::Arc.
22 23 24 |
# File 'lib/geometry/arc.rb', line 22 def radius @radius end |
#start_angle ⇒ Number (readonly)
Returns the starting angle of the Geometry::Arc as radians from the x-axis.
25 26 27 |
# File 'lib/geometry/arc.rb', line 25 def start_angle @start_angle end |
Class Method Details
.new(center, start, end) ⇒ Arc, ThreePointArc .new(center, radius, start, end) ⇒ Arc, ThreePointArc
43 44 45 46 47 48 49 50 51 |
# File 'lib/geometry/arc.rb', line 43 def self.new(={}) center = .delete(:center) || PointZero.new if .has_key?(:radius) original_new(center, [:radius], [:start], [:end]) else ThreePointArc.new(center, [:start], [:end]) end end |
Instance Method Details
#first ⇒ Point
Returns The starting point of the Geometry::Arc.
67 68 69 |
# File 'lib/geometry/arc.rb', line 67 def first @center + @radius * Vector[Math.cos(@start_angle), Math.sin(@start_angle)] end |
#last ⇒ Point
Returns The end point of the Geometry::Arc.
72 73 74 |
# File 'lib/geometry/arc.rb', line 72 def last @center + @radius * Vector[Math.cos(@end_angle), Math.sin(@end_angle)] end |