Class: GeoTriangleExt::CircumCenter
- Inherits:
-
Object
- Object
- GeoTriangleExt::CircumCenter
- Defined in:
- lib/geo_triangle_ext/circum_center.rb
Class Method Summary collapse
Instance Method Summary collapse
- #center ⇒ Object
- #coordinates ⇒ Object
- #functions ⇒ Object
- #set_coordinate(x, y) ⇒ Object
- #valid_coordinates? ⇒ Boolean
- #valid_functions? ⇒ Boolean
Class Method Details
.create(*co) ⇒ Object
8 9 10 11 12 |
# File 'lib/geo_triangle_ext/circum_center.rb', line 8 def create(*co) cc = self.new co.take(3).each{|c| cc.coordinates << c} cc end |
Instance Method Details
#center ⇒ Object
45 46 47 48 49 |
# File 'lib/geo_triangle_ext/circum_center.rb', line 45 def center return unless valid_functions? @center_point ||= calc_center @center_point end |
#coordinates ⇒ Object
20 21 22 23 24 25 |
# File 'lib/geo_triangle_ext/circum_center.rb', line 20 def coordinates @coordinates ||= [] @coordinates = @coordinates.uniq @coordinates = @coordinates.take(3) if @coordinates.size > 3 @coordinates end |
#functions ⇒ Object
33 34 35 36 |
# File 'lib/geo_triangle_ext/circum_center.rb', line 33 def functions @functions ||= create_functions @functions end |
#set_coordinate(x, y) ⇒ Object
16 17 18 |
# File 'lib/geo_triangle_ext/circum_center.rb', line 16 def set_coordinate(x, y) coordinates << [x, y] end |
#valid_coordinates? ⇒ Boolean
27 28 29 30 31 |
# File 'lib/geo_triangle_ext/circum_center.rb', line 27 def valid_coordinates? return false unless coordinates.size == 3 return false unless coordinates.all?{|c| c.size == 2} true end |
#valid_functions? ⇒ Boolean
38 39 40 41 42 43 |
# File 'lib/geo_triangle_ext/circum_center.rb', line 38 def valid_functions? return false if functions.size < 2 return false if functions.combination(2).any?{|f1, f2| f1.orthogonal_slope == f2.orthogonal_slope} true end |