Skip to content

Commit 3921ac1

Browse files
committed
move to library example
1 parent 840a50d commit 3921ac1

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

processing_app/library/vecmath/vec2d/README.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

contributed/circles.rb renamed to processing_app/library/vecmath/vec2d/circles.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def setup
1717
@c = rand(360)
1818
@points = (0..2).map { Point.new(rand(width), rand(height)) }
1919
background 0
20+
ellipse_mode RADIUS
2021
end
2122

2223
def draw
@@ -35,19 +36,19 @@ def draw
3536
no_fill
3637
# verifies if there is a circle and draw it
3738
return if collinear(@points[0].pos, @points[1].pos, @points[2].pos)
38-
draw_circle @points
39+
draw_circle *@points
3940
end
4041

41-
def draw_circle(pts)
42+
def draw_circle(a, b, c)
4243
# find the bisectors of 2 sides
4344
mp = []
44-
mp[0] = bisector(pts[0].pos, pts[1].pos)
45-
mp[1] = bisector(pts[1].pos, pts[2].pos)
45+
mp << bisector(a.pos, b.pos)
46+
mp << bisector(b.pos, c.pos)
4647
center_point = center(mp) # find the center of the circle
4748
# calculate the radius
48-
radius = center_point.dist(pts[2].pos)
49+
radius = center_point.dist(c.pos)
4950
# if not collinear display circle
50-
ellipse(center_point.x, center_point.y, 2 * radius, 2 * radius)
51+
ellipse(center_point.x, center_point.y, radius, radius)
5152
end
5253

5354
def bisector(a, b)
@@ -102,7 +103,7 @@ def update
102103
@pos += velocity
103104
end
104105

105-
def check_edges
106+
def check_edges # could be more sophisticated, eg reverse velocity
106107
pos.x = constrain(pos.x, 0, width)
107108
pos.y = constrain(pos.y, 0, height)
108109
end

0 commit comments

Comments
 (0)