Search the Community
Showing results for tags 'circles'.
Found 2 results
-
Goal: Looking into tangent lines between two circles and trying to convert this function into vex. The code is originally in Java but looks like it should be easily converted to vex but I'm getting errors with my attempt below. function float[] common_tangent_line(x1, y1, r1, x2, y2, r2) { // Compute the common tangent line of two circles: (x1, y1) - r1 and (x2, y2) - r2 // Return in the form of line equation: ax + by + c == 0 delta1 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) - (r1 + r2) * (r1 + r2); delta2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) - (r1 - r2) * (r1 - r2); p1 = r1 * (x1 * x2 + y1 * y2 - x2 * x2 - y2 * y2); p2 = r2 * (x1 * x1 + y1 * y1 - x1 * x2 - y1 * y2); q = x1 * y2 - x2 * y1; results = []; if(delta1 >= 0) { l11 = { a: (x2 - x1) * (r1 + r2) + (y1 - y2) * Math.sqrt(delta1), b: (y2 - y1) * (r1 + r2) + (x2 - x1) * Math.sqrt(delta1), c: p1 + p2 + q * Math.sqrt(delta1) }; l12 = { a: (x2 - x1) * (r1 + r2) - (y1 - y2) * Math.sqrt(delta1), b: (y2 - y1) * (r1 + r2) - (x2 - x1) * Math.sqrt(delta1), c: p1 + p2 - q * Math.sqrt(delta1) }; results.push(l11); results.push(l12); } if(delta2 >= 0) { l21 = { a: (x2 - x1) * (r1 - r2) + (y1 - y2) * Math.sqrt(delta2), b: (y2 - y1) * (r1 - r2) + (x2 - x1) * Math.sqrt(delta2), c: p1 - p2 + q * Math.sqrt(delta2) }; l22 = { a: (x2 - x1) * (r1 - r2) - (y1 - y2) * Math.sqrt(delta2), b: (y2 - y1) * (r1 - r2) - (x2 - x1) * Math.sqrt(delta2), c: p1 - p2 - q * Math.sqrt(delta2) }; results.push(l21); results.push(l22); } return results; }
-
Hey, I would ideally like to have this all happen in Vex rather than the set I have made here. This would allow it to be more scalable, but perhaps I can save that for my next problem. Right now I am wondering how I go about recreating the curve I have outlined in pink on the image? Any ideas would be a big help as I'm really stuck. Thanks Metaball Arc_Circles_A_01.hip