Haskell-Things / Haskell-Things/ImplicitCAD
Small polygons under rotation result in SDF flipping its sign
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
These two should be equal, but internally when sampled at `(V2 (-1) 0)`
the sign of the SDF differs yet they both get rendered correctly.
```haskell
let funPoly = polygon [V2 0 0, V2 0 (-0.1), V2 (-2) 0, V2 0 (-1)]
rotFunPoly = rotate (2*pi) funPoly
```
```haskell
> getImplicit funPoly (V2 (-1) 0)
-4.993761694389224e-2
> getBox funPoly
(V2 (-2.0) (-1.0),V2 0.0 0.0)
```
vs
```haskell
> getImplicit rotFunPoly (V2 (-1) 0))
4.9937616943891996e-2
> getBox rotFunPoly
(V2 (-2.0000000000000004) (-1.0),V2 0.0 4.898587196589413e-16)
```
This has something to do with `isIn` https://github.com/Haskell-Things/ImplicitCAD/blob/874cb7673ef8b81b022249c3604d477519dfe057/Graphics/Implicit/ObjectUtil/GetImplicit2.hs#L60
and https://github.com/Haskell-Things/ImplicitCAD/blob/874cb7673ef8b81b022249c3604d477519dfe057/Graphics/Implicit/ObjectUtil/GetImplicit2.hs#L49-L56
and it only seems to affect small polygons + rotation. If the `isIn` mechanism is dropped, they don't get rendered at all.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.