Skip to content

Commit 840a50d

Browse files
committed
circles
1 parent f611bab commit 840a50d

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

contributed/circles.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def draw
2525
rect(0, 0, width, height) if (frame_count % 8_000).zero?
2626
@points.each do |point|
2727
# change direction sometimes
28-
point.set_dir rand(-PI..PI) if rand > 0.96
28+
point.direction rand(-PI..PI) if rand > 0.96
2929
point.update
3030
point.check_edges
3131
end
@@ -69,12 +69,13 @@ def center(bisector)
6969
end
7070
# calculate x and y coordinates of the circumcenter
7171
ox = (eq[1].y * eq[0].z - eq[0].y * eq[1].z) /
72-
(eq[0].x * eq[1].y - eq[1].x * eq[0].y)
73-
oy = (eq[0].x * eq[1].z - eq[1].x * eq[0].z) /
74-
(eq[0].x * eq[1].y - eq[1].x * eq[0].y)
75-
Vec2D.new(ox,oy)
72+
(eq[0].x * eq[1].y - eq[1].x * eq[0].y)
73+
oy = (eq[0].x * eq[1].z - eq[1].x * eq[0].z) /
74+
(eq[0].x * eq[1].y - eq[1].x * eq[0].y)
75+
Vec2D.new(ox, oy)
7676
end
7777

78+
# Moving point class
7879
class Point
7980
include Processing::Proxy
8081
attr_accessor :pos, :velocity, :acceleration
@@ -86,7 +87,7 @@ def initialize(x, y)
8687
end
8788

8889
# change direction
89-
def set_dir(angle)
90+
def direction(angle)
9091
# direction of the acceleration is defined by the new angle
9192
@acceleration = Vec2D.from_angle(angle)
9293
dif = acceleration.angle_between velocity

0 commit comments

Comments
 (0)