Last active
August 20, 2023 20:30
-
-
Save mcsee/4135a48a51ff4361359326f2d4b2076e to your computer and use it in GitHub Desktop.
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
<? | |
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