by benfrederickson · 11y ago · 0 comments
Anyways, If you have any questions ask away =).
Math.sqrt((p.x - c.x) ^ 2 + (p.y - c.y) ^ 2) > c.radius
If you're doing this test many, many times (especially as in a Monte Carlo simulation), it'd be more efficient to use distanceSquared: (p.x - c.x) ^ 2 + (p.y - c.y) ^ 2 > c.radius ^ 2
Not having to calculate square roots will cut the compute time drastically.I didn't think of it when I was writing this post though =(
Is that something you did in your research?