Class: Circumcircle

Inherits:
Object
  • Object
show all
Defined in:
lib/math_demo/circumcircle.rb

Overview

Circumcircle from 3 points

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(points) ⇒ Circumcircle

Returns a new instance of Circumcircle.



7
8
9
# File 'lib/math_demo/circumcircle.rb', line 7

def initialize(points)
  @points = points
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



6
7
8
# File 'lib/math_demo/circumcircle.rb', line 6

def center
  @center
end

#pointsObject (readonly)

Returns the value of attribute points.



6
7
8
# File 'lib/math_demo/circumcircle.rb', line 6

def points
  @points
end

#radiusObject (readonly)

Returns the value of attribute radius.



6
7
8
# File 'lib/math_demo/circumcircle.rb', line 6

def radius
  @radius
end

Instance Method Details

#calculateObject



11
12
13
14
# File 'lib/math_demo/circumcircle.rb', line 11

def calculate
  @center = Vec2D.new(-(bx / am), -(by / am))
  @radius = center.dist(points[2]) # points[2] = c
end