-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tetrahedron sampling #13430
Tetrahedron sampling #13430
Conversation
let [a, b, c, d] = self.vertices; | ||
[ | ||
Triangle3d::new(b, c, d), | ||
Triangle3d::new(a, c, d).reversed(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the compiler will probably crunch through this, esp. given the #[inline] but couldn't we just reorder the arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess so, but I thought this would make it clearer what's actually going on, since the relationship between vertex order and orientation is otherwise not that clear (e.g. the choice of which vertices to interchange when Triangle3d::reverse
is called is essentially arbitrary).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is clearer to me.
A neat little theorem in there about linear transformations preserving probability densities correctly. Do you have a citation at hand? |
I guess this is just the standard fact that the Lebesgue measure of a linearly transformed set is the original Lebesgue measure times the determinant of the linear transformation. I can't find a great standalone source, but I guess I could just link to something like the Wikipedia article. |
Objective
Add interior and boundary sampling for the
Tetrahedron
primitive. This is part of ongoing work to bring the primitives to parity with each other in terms of their capabilities.Solution
Tetrahedron
implements theShapeSample
trait. To support this, there is a new public methodTetrahedron::faces
which gets the faces of a tetrahedron asTriangle3d
s. There are more sophisticated ideas for getting the faces we might want to consider in the future (e.g. adjusting according to the orientation), but this method gives the most mathematically straightforward answer, giving the faces the orientation induced by the tetrahedron itself.