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 ⇒ Object
readonly
Returns the value of attribute end_angle.
-
#radius ⇒ Object
readonly
Returns the value of attribute radius.
-
#start_angle ⇒ Object
readonly
Returns the value of attribute start_angle.
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
52 53 54 55 56 57 |
# File 'lib/geometry/arc.rb', line 52 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 ⇒ Object (readonly)
Returns the value of attribute end_angle.
21 22 23 |
# File 'lib/geometry/arc.rb', line 21 def end_angle @end_angle end |
#radius ⇒ Object (readonly)
Returns the value of attribute radius.
20 21 22 |
# File 'lib/geometry/arc.rb', line 20 def radius @radius end |
#start_angle ⇒ Object (readonly)
Returns the value of attribute start_angle.
21 22 23 |
# File 'lib/geometry/arc.rb', line 21 def start_angle @start_angle end |
Class Method Details
.new(center, start, end) ⇒ Arc, ThreePointArc .new(center, radius, start, end) ⇒ Arc, ThreePointArc
36 37 38 39 40 41 42 43 44 |
# File 'lib/geometry/arc.rb', line 36 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.
60 61 62 |
# File 'lib/geometry/arc.rb', line 60 def first @center + @radius * Vector[Math.cos(@start_angle), Math.sin(@start_angle)] end |
#last ⇒ Point
Returns The end point of the Geometry::Arc.
65 66 67 |
# File 'lib/geometry/arc.rb', line 65 def last @center + @radius * Vector[Math.cos(@end_angle), Math.sin(@end_angle)] end |