Skip to content

Instantly share code, notes, and snippets.

@PEMapModder
Last active November 18, 2015 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PEMapModder/c59a1c2f3cfe01884e6b to your computer and use it in GitHub Desktop.
Save PEMapModder/c59a1c2f3cfe01884e6b to your computer and use it in GitHub Desktop.
<?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