Point in the circle (v5)

Revision 5 of this benchmark created on


Setup

center = 0;
  radius = 50;

Test runner

Ready to run.

Testing in
TestOps/sec
Pythagoras
for (x = center - radius; x < center + radius; x++) {
  for (y = center - radius; y < center + radius; y++) {
    if ((x - center) * (x - center) + (y - center) * (y - center) < radius * radius) {

    }
  }
}
ready
Trigonometry
for (x = center - radius; x < center + radius; x++) {
  yspan = Math.round(radius * Math.sin(Math.acos((center - x) / radius)));
  for (y = center - yspan; y < center + yspan; y++) {

  }
}
ready
Symmetry
radiusSquared = radius * radius;
xStart = center - radius;
yStart = center - radius;
for (x = xStart; x <= center; x++) {
  xSquared = (x - center) * (x - center);
  for (y = yStart; y <= center; y++) {
    ySquared = (y - center) * (y - center);
    if (xSquared + ySquared < radiusSquared) {

    }
  }
}
ready
Symmetry + Trigonometry
for (x = center - radius; x <= center; x++) {
  yspan = Math.round(radius * Math.sin(Math.acos((center - x) / radius)));
  for (y = center - yspan; y <= center; y++) {

  }
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.