Last active
November 18, 2015 14:44
-
-
Save PEMapModder/c59a1c2f3cfe01884e6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* @param number $x the X coordinate of the center of the circle | |
* @param number $y the Y coordinate to place particles at | |
* @param number $z the Z coordinate of the center of the circle | |
* @param number $radius the distance for each dot from the center | |
* @param number $step the angle per step, in degrees | |
* @param callable $callback the function to call for each dot, with parameters $x, $y, $z representing the coordinates of the dot | |
*/ | |
function dot($x, $y, $z, $radius, $step, callable $callback){ | |
$step *= M_PI / 180; // equivalent to deg2rad, but faster | |
for($r = 0; $r < M_PI_2; $r += $step){ | |
$tx = -sin($r) * $radius + $x; | |
$tz = cos($r) * $radius + $z; | |
$callback($tx, $y, $tz); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment