create continuous, smooth spinner outline
authordaniel watson <ozzloy@gmail.com>
Tue, 27 Dec 2016 09:37:15 +0000 (01:37 -0800)
committerdaniel watson <ozzloy@gmail.com>
Tue, 27 Dec 2016 09:37:15 +0000 (01:37 -0800)
spin-data.scad
spin.scad

index ae9c89e198d22bbcb5d470a78d66a5ee231bb044..9190e9a035145e49e674d07ede0097678ff018ab 100644 (file)
@@ -2,24 +2,81 @@
    see bottom for more license info */
 
 /* spin thing that erin likes */
-$fn = 50;
+$fn = 500;
 
 weight = "penny";
 // weight = "608zz";
+bearing = "608zz";
 wall_thickness = 2;
 _608zz_radius = 22;
 penny_radius = 19.05 / 2;
 penny_thickness = 1.52;
 weight_radius = (weight == "penny") ? penny_radius : _608zz_radius;
+bearing_radius = (bearing == "608zz") ? _608zz_radius : 1/0;
 arms = 3;
 
-module spin(weight_radius, arms, wall_thickness) {
-  _608zz_holder_radius = _608zz_radius + wall_thickness;
-  circle(_608zz_holder_radius);
+module spin(weight_radius,
+            arms,
+            wall_thickness,
+            bearing_radius) {
+  bearing_holder_radius = bearing_radius + wall_thickness;
   weight_holder_radius = weight_radius + wall_thickness;
+
+  circle(bearing_holder_radius);
+
+  /*
+   * imagine a right triangle with one point at the origin, at the
+   * center of the spinning bearing holder, one point in the middle of
+   * the weight holder, and one point at the center of a circle tangent
+   * to the first two, called the joiner circle.
+   * the radius of the joiner circle is the arithmetic average of the
+   * weight holder and bearing holder.
+   */
+  joiner_radius = (bearing_holder_radius + weight_holder_radius) / 2;
+  /* a: goes between the center of the weight holder and the center of
+     the joiner circle. */
+  a = joiner_radius + weight_holder_radius;
+  /* b: length of the base, which goes along the x-axis between
+     the origin and the center of the weight holder. */
+  b = weight_holder_radius + bearing_holder_radius;
+  /* c: goes between origin and joiner circle. */
+  c = bearing_holder_radius + joiner_radius;
+
+  /* A: angle at the origin, between the base and hypotenuse.
+     it is calculated using law of cosines, given the lengths of
+     all 3 sides of the triangle. */
+  A = acos((pow(b, 2) + pow(c, 2) - pow(a, 2)) / (2 * b * c));
+  /* find the center of the joiner circle */
+  joiner_x = cos(A) * c;
+  joiner_y = sin(A) * c;
+
+  /* find the points where the circles meet */
+  bearing_joiner_point = [cos(A) * bearing_holder_radius,
+                          sin(A) * bearing_holder_radius];
+  bearing_weight_point = [bearing_holder_radius, 0];
+  /* C: angle between x-axis and line-segment between center of weight
+     holder and center of joiner.
+     it is calculated using law of cosines, given the lengths of
+     all 3 sides of the triangle. */
+  C = acos((pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2 * a * b));
+  weight_joiner_point = [b - cos(C) * weight_holder_radius,
+                         sin(C) * weight_holder_radius];
   for(arm = [0 : arms - 1]) {
     rotate(arm * 360.0 / arms) {
-      translate([weight_holder_radius + _608zz_holder_radius, 0]) {
+      difference() {
+        polygon([bearing_weight_point,
+                 bearing_joiner_point,
+                 weight_joiner_point]);
+        translate([joiner_x, joiner_y]) {
+          circle(joiner_radius); } }
+      mirror(v = [0, 1, 0]) {
+        difference() {
+          polygon([bearing_weight_point,
+                   bearing_joiner_point,
+                   weight_joiner_point]);
+          translate([joiner_x, joiner_y]) {
+            circle(joiner_radius); } } }
+      translate([weight_holder_radius + bearing_holder_radius, 0]) {
         circle(weight_holder_radius); } } } }
 
 /*
index e75fe142021d21944605e1dcc6edafd0c10b8f68..e07088207c7be6a7ea6f09efe062e9bb093023c3 100644 (file)
--- a/spin.scad
+++ b/spin.scad
@@ -4,7 +4,7 @@
 /* spin thing that erin likes */
 include<spin-data.scad>
 
-spin(weight_radius, arms, wall_thickness);
+spin(weight_radius, arms, wall_thickness, bearing_radius);
 
 /*
   This file is part of 3d-printables.