TrigonometryTest.php 927 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace MathPHP\Tests;
  3. use MathPHP\Trigonometry;
  4. class TrigonometryTest extends \PHPUnit\Framework\TestCase
  5. {
  6. /**
  7. * @test unitCircle returns points on a unit circle.
  8. * @dataProvider dataProviderForUnitCircle
  9. * @param int $points
  10. * @param array $expected
  11. */
  12. public function testUnitCircle(int $points, array $expected)
  13. {
  14. // When
  15. $unitCircle = Trigonometry::unitCircle($points);
  16. // Then
  17. $this->assertEqualsWithDelta($expected, $unitCircle, 0.00000001);
  18. }
  19. /**
  20. * @return array
  21. */
  22. public function dataProviderForUnitCircle(): array
  23. {
  24. return [
  25. [5, [[1, 0], [0, 1], [-1, 0], [0, -1], [1, 0]]],
  26. [9, [[1, 0], [\M_SQRT1_2, \M_SQRT1_2], [0, 1], [-\M_SQRT1_2, \M_SQRT1_2], [-1, 0], [-\M_SQRT1_2, -\M_SQRT1_2], [0, -1], [\M_SQRT1_2, -\M_SQRT1_2], [1, 0]]],
  27. ];
  28. }
  29. }