1
2
3
4
5
6
7
8
9
10
11
12
|
// Zufällige kartesische Koordinaten erzeugen
vector3f x = random_vector3f();
// Umwandeln in sphärische Koordinaten (r,rotX,rotZ)
float r = sqrt(x.x*x.x+x.y*x.y+x.z*x.z);
float rotX = std::atan2( sqrt(x.x*x.x+x.y*x.y) , x.z );
float rotZ = std::atan2(x.y , x.x);
// Rückrechnen wieder in kartesische Koordinaten:
x.x = r * sin(rotX) * cos(rotZ);
x.y = r * sin(rotX) * sin(rotZ);
x.z = r * cos(rotX);
|