| 155 | } |
| 156 | |
| 157 | Vector3 GeneratePointInSpheroid(const Vector3& center, const EulerAngles& orient, const Vector3& semiMajorAxis) |
| 158 | { |
| 159 | // Use rejection sampling method. |
| 160 | auto relPoint = Vector3::Zero; |
| 161 | do |
| 162 | { |
| 163 | relPoint = Vector3( |
| 164 | Random::GenerateFloat(-semiMajorAxis.x, semiMajorAxis.x), |
| 165 | Random::GenerateFloat(-semiMajorAxis.y, semiMajorAxis.y), |
| 166 | Random::GenerateFloat(-semiMajorAxis.z, semiMajorAxis.z)); |
| 167 | } |
| 168 | while ((SQUARE(relPoint.x) / SQUARE(semiMajorAxis.x) + |
| 169 | SQUARE(relPoint.y) / SQUARE(semiMajorAxis.y) + |
| 170 | SQUARE(relPoint.z) / SQUARE(semiMajorAxis.z)) > 1.0f); |
| 171 | |
| 172 | // Rotate relative point. |
| 173 | auto rotMatrix = orient.ToRotationMatrix(); |
| 174 | relPoint = Vector3::Transform(relPoint, rotMatrix); |
| 175 | |
| 176 | return (center + relPoint); |
| 177 | } |
| 178 | |
| 179 | bool TestProbability(float prob) |
| 180 | { |
no test coverage detected