Add ray marching
nobodyinperson opened this issue · comments
Yann Büchau commented
goal is to find the distance the object takes up along a given axis. Either between two points or alone a given line (point + direction).
Two methods:
- ray marching from both ends simultaneously (if overlap, abort)
- find roots with optimization: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html
1D ray marching is easy as described above.
2D would be useful e.g. to find bounding box:
- define function for distance to given plane (point+normal)
- scipy optimize minimize of 2D coordinates on plane, cost function is direcly the SDF, params are 2D coordinates, resulting cost is minimum dostance
- find root of that plane distance function alone given path
use cases:
- find size of of object
- find boundary of object to move it e.g. into positve z
Yann Büchau commented
Quick scipy.optimize.root
tests:
- method lm seems to do the intuitive thing, medium speed
- method broyden2 and more so df.sane are very fast but sometimes find weird roots
Yann Büchau commented
Nested optimization works and is quite fast