float3 Capsule::RandomPointInside(LCG &rng) const { assume(IsFinite()); OBB obb = MinimalEnclosingOBB(); for(int i = 0; i < 1000; ++i) { float3 pt = obb.RandomPointInside(rng); if (Contains(pt)) return pt; } assume(false && "Warning: Capsule::RandomPointInside ran out of iterations to perform!"); return Center(); // Just return some point that is known to be inside. }
float3 Frustum::UniformRandomPointInside(LCG &rng) const { if (type == OrthographicFrustum) return FastRandomPointInside(rng); else { OBB o = MinimalEnclosingOBB(); for(int numTries = 0; numTries < 1000; ++numTries) { float3 pt = o.RandomPointInside(rng); if (Contains(pt)) return pt; } LOGW("Rejection sampling failed in Frustum::UniformRandomPointInside! Producing a non-uniformly distributed point inside the frustum!"); return FastRandomPointInside(rng); } }
float3 Capsule::UniformPointPerhapsInside(float l, float x, float y) const { return MinimalEnclosingOBB().PointInside(l, x, y); }