On Thursday, 13 May 2021 at 03:03:37 UTC, Tim wrote:
```
unittest{
    auto p = rotate2D([0.0, 10.0], PI_2);
    assert(p == [-10.0, 0.0]);
}
```

I suggest

```
unittest
{
    auto p = rotate2D([0.0, 10.0], PI_2);
    assert(isClose(p[0], -10.0));
    assert(isClose(p[1], 0.0, 0.0, 1e-6));
}
```

In the second test, the value is compared against zero, which is somewhat special - you need to specify an acceptable distance from zero to get it right.

You could also improve your result by making the `phi` a `double` value. In this case you can replace the `1e-6` above by `1e-15` which is much closer to zero.

Reply via email to