Cartesian to polar coordinates
问题 Take a look at the example here: http://www.brianhare.com/physics/so.html Take a look at console.log where I am using these two main functions: function distanceBetween2pts(x1, y1, x2, y2) { console.log("Particle: ("+x1+","+y1+") Mouse: ("+x2+","+y2+")"); // Pythagoras Theorem // PQ = sqrt( (x2-x1)^2 + (y2-y1)^2 ) var x = (x2-x1); var y = (y2-y1); this.radius = Math.sqrt(x*x + y*y); this.x = x; this.y = y; } function polar2cartesian(R, theta) { this.x = R * Math.cos(theta); this.y= R * Math