Fix Triangle2d/Triangle3d interior sampling to correctly follow triangle (#12766)

# Objective

When I wrote #12747 I neglected to translate random samples from
triangles back to the point where they originated, so they would be
sampled near the origin instead of at the actual triangle location.

## Solution

Translate by the first vertex location so that the samples follow the
actual triangle.
This commit is contained in:
Matty 2024-03-29 09:10:23 -04:00 committed by GitHub
parent 741803d8c9
commit bcdb20d4f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -159,9 +159,9 @@ fn sample_triangle_interior<P: NormedVectorSpace, R: Rng + ?Sized>(
if u + v > 1. {
let u1 = 1. - v;
let v1 = 1. - u;
ab * u1 + ac * v1
a + (ab * u1 + ac * v1)
} else {
ab * u + ac * v
a + (ab * u + ac * v)
}
}