Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaschen committed Jun 4, 2022
1 parent 173b130 commit 0c528c9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/300_Comparisons/320_Directions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Directions

With the `Direction` class it's possible to determine if one point is north, east, south or west of another point.

```php
<?php

use Location\Coordinate;

$berlin = new Coordinate(52.5, 13.5);
$rome = new Coordinate(42, 12.5);
$helsinki = new Coordinate(60, 25);

$direction = new Direction();

if ($direction->pointIsNorthOf(point: $helsinki, compareAgainst: $berlin)) {
echo 'Helsinki is located north of Berlin.' . PHP_EOL;
} else {
echo 'Berlin is located north of Helsinki.' . PHP_EOL;
}

if ($direction->pointIsEastOf(point: $rome, compareAgainst: $berlin)) {
echo 'Rome is located east of Berlin.' . PHP_EOL;
} else {
echo 'Berlin is located east of Rome.' . PHP_EOL;
}
```

The code above will produce the output below:

``` plaintext
Helsinki is located north of Berlin.
Berlin is located east of Rome.
```
File renamed without changes.

0 comments on commit 0c528c9

Please sign in to comment.