I have two cartesian points and I want to know the distance between them. I wrote the follow function:

function distance(p1, p2) {

return Math.sqrt(Math.pow((p1.x - p2.x), 2) + Math.pow((p1.y - p2.y), 2));

}

But it is not right.

My application draws a circle with mouse. When the mouse moves on horizontal It’s ok:

But on vertical the radius is lesser:

where p1 is center and p2 is the mouse position. It’s a cartesian coordinates problem?

Thanks!