Skip to content

Commit aa791ce

Browse files
committed
2 parents c0bd005 + 55036ec commit aa791ce

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

processing_app/library/vecmath/vec2d/library/circles/lib/circumcircle.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# Circumcircle from 3 points
1+
# frozen_string_literal: true
22
require 'matrix'
33

4+
# Circumcircle from 3 points
45
class Circumcircle
56
attr_reader :center, :radius, :points
67
def initialize(points)
@@ -19,25 +20,19 @@ def calculate
1920

2021
def am
2122
2 * Matrix[
22-
[points[0].x, points[0].y, 1],
23-
[points[1].x, points[1].y, 1],
24-
[points[2].x, points[2].y, 1]
23+
*points.map { |pt| [pt.x, pt.y, 1] }
2524
].determinant
2625
end
2726

2827
def bx
2928
-Matrix[
30-
[points[0].x * points[0].x + points[0].y * points[0].y, points[0].y, 1],
31-
[points[1].x * points[1].x + points[1].y * points[1].y, points[1].y, 1],
32-
[points[2].x * points[2].x + points[2].y * points[2].y, points[2].y, 1]
29+
*points.map { |pt| [pt.x * pt.x + pt.y * pt.y, pt.y, 1] }
3330
].determinant
3431
end
3532

3633
def by
3734
Matrix[
38-
[points[0].x * points[0].x + points[0].y * points[0].y, points[0].x, 1],
39-
[points[1].x * points[1].x + points[1].y * points[1].y, points[1].x, 1],
40-
[points[2].x * points[2].x + points[2].y * points[2].y, points[2].x, 1]
35+
*points.map { |pt| [pt.x * pt.x + pt.y * pt.y, pt.x, 1] }
4136
].determinant
4237
end
4338
end

0 commit comments

Comments
 (0)