Created
January 26, 2018 22:14
-
-
Save net8floz/1af98cfc25d0bd4a5f5729b0298dffb5 to your computer and use it in GitHub Desktop.
Compare distances while avoiding square roots!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///@function point_distance_squared(x1, y1, x2, y2) | |
///@desc Compare distances while avoiding square roots! If you must compare | |
/// the result with a non squared value... simply square it! | |
/// if(point_distance_squared() > max * max){ | |
/// | |
/// } | |
///@param x1 | |
///@param y1 | |
///@param x2 | |
///@param y2 | |
var _x1 = argument0, | |
_y1 = argument1, | |
_x2 = argument2, | |
_y2 = argument3, | |
_dx = (_x2 - _x1), | |
_dy = (_y2 - _y1); | |
return _dx * _dx + _dy * _dy; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment