MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / createSphere

Function createSphere

cpp/4_CUDA_Libraries/randomFog/randomFog.cpp:150–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void createSphere(void)
151{
152 int startVertex = 0;
153
154 for (int i = startVertex; i < g_nVerticesPopulated; i++) {
155 float r;
156 float rho;
157 float theta;
158
159 if (g_currentShape == Sphere) {
160 r = g_pRng->getNextU01();
161 r = powf(r, 1.f / 3.f);
162
163 for (int j = 0; j < nSkip3; j++) {
164 g_pRng->getNextU01();
165 }
166 }
167 else {
168 r = 1.0f;
169 }
170
171 rho = g_pRng->getNextU01() * PI * 2.0f;
172
173 for (int j = 0; j < nSkip1; j++) {
174 g_pRng->getNextU01();
175 }
176
177 theta = (g_pRng->getNextU01() * 2.0f) - 1.0f;
178 theta = asin(theta);
179
180 for (int j = 0; j < nSkip2; j++) {
181 g_pRng->getNextU01();
182 }
183
184 g_pVertices[i].x = r * fabs(cos(theta)) * cos(rho);
185 g_pVertices[i].y = r * fabs(cos(theta)) * sin(rho);
186 g_pVertices[i].z = r * sin(theta);
187
188 g_pVertices[i].r = 1.0f;
189 g_pVertices[i].g = 1.0f;
190 g_pVertices[i].b = 1.0f;
191 }
192}
193
194void createAxes(void)
195{

Callers 3

reCreateFunction · 0.85
keyboardFunction · 0.85
mainFunction · 0.85

Calls 5

asinFunction · 0.85
fabsFunction · 0.85
cosFunction · 0.85
sinFunction · 0.85
getNextU01Method · 0.80

Tested by

no test coverage detected