MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / GeneratePointOnSphere

Function GeneratePointOnSphere

TombEngine/Math/Random.cpp:142–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140 }
141
142 Vector3 GeneratePointOnSphere(const BoundingSphere& sphere)
143 {
144 float u = GenerateFloat(0.0f, 1.0f);
145 float v = GenerateFloat(0.0f, 1.0f);
146
147 float theta = u * PI_MUL_2;
148 float phi = acos((v * 2) - 1.0f);
149
150 auto relPoint = Vector3(
151 sin(phi) * cos(theta),
152 sin(phi) * sin(theta),
153 cos(phi));
154 return (sphere.Center + (relPoint * sphere.Radius));
155 }
156
157 Vector3 GeneratePointInSpheroid(const Vector3& center, const EulerAngles& orient, const Vector3& semiMajorAxis)
158 {

Callers 2

SpawnElectricEffectFunction · 0.85

Calls 2

GenerateFloatFunction · 0.85
Vector3Function · 0.50

Tested by

no test coverage detected