flash - Determine the centre/center of a circle using multiple points -


i wondering if me, can on pen , paper using compass, can't in actionscript 3.

as title says, need find centre of circle using multiple points radius.

you want equation circle 3 points. dr. math has some nice explanations on question.

edit: i've implemented in javascript + svg; can see interactive result on website:
http://phrogz.net/svg/3-point-circle.xhtml

here's relevant code (i've created point class in actionscript .x , .y properties):

function findcirclecenter(p1,p2,p3){   var d2  = p2.x*p2.x + p2.y*p2.y;   var bc  = (p1.x*p1.x + p1.y*p1.y - d2) / 2;   var cd  = (d2 - p3.x*p3.x - p3.y*p3.y) / 2;   var det = (p1.x-p2.x) * (p2.y-p3.y) - (p2.x-p3.x) * (p1.y-p2.y);   if (math.abs(det) > 1e-10) return new point(     (bc * (p2.y-p3.y) - cd * (p1.y-p2.y)) / det,     ((p1.x-p2.x) * cd - (p2.x-p3.x) * bc) / det   ); } 

edit 2: fun, instead of 3 points defining 1 circle, how 6 points defining 20? :)
http://phrogz.net/svg/3-point-circle2.xhtml


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -