Add SphereInCuboid geometry
Checklist:
- [x] Opened an issue
- [x] Referenced the relevant issue number(s) below
- [x] Provided a description of the changes below
- [ ] Ensured all tests pass and added any necessary tests for new code
Fixes #290. This PR does not have any tests yet since I'd like to have someone check the correctness of my approach first.
Description
This PR is mainly the addition of the file sphereincuboid.rs. It tries to incorporate a sphere of one material in another cuboid material (a very specific inhomogeneous 3d geometry). The sphere is centered at the origin, and the rectangular cuboid is axis-aligned and must envelop the sphere. The essential inputs are the sphere radius and the lower/upper corners of the cuboid.
Tests
The compilation is done on Linux-6.16.
This PR doesn't have any guardrails/tests yet. For example, I don't check if the sphere is entirely inside the cuboid or not. However, I plan to write tests in the future.
Hi @ATM-Jahid - thanks for your work on this! I'll take a detailed look at it when I can. For now, I've taken a quick look and approved the Github actions workflow on this PR.
Do you think it would be feasible to extend this a little, for example, to consider multiple spheres, or even a union of any number of 3D shapes?
I think it'd be easy to extend the current implementation to have multiple non-overlapping spheres in a cuboid. I don't think I can work on extending it now though, since I'm in the middle of finishing my dissertation and trying to find a job.
For a union of non-overlapping 3D shapes, I assume the implementation would not be hard with parry3d. At first, I was trying to do it with parry3d before the problem of embedding one shape into another came up. My initial idea was to introduce a z-order for the overlapping shapes in the input. Maybe I'll try to implement the idea if I get some free time.