Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active August 20, 2023 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcsee/4135a48a51ff4361359326f2d4b2076e to your computer and use it in GitHub Desktop.
Save mcsee/4135a48a51ff4361359326f2d4b2076e to your computer and use it in GitHub Desktop.
<?
final class Point {
private $rho;
private $theta;
public function x() {
return $this->rho * cos($this->theta);
}
public function y() {
return $this->rho * sin($this->theta);
}
}
final class DistanceCalculator {
function distanceBetween(Point $origin, Point $destination) {
return sqrt((($destination->x() - $origin->x() ^ 2) +
(($destination->y() - $origin->y()) ^ 2)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment