Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- F32 x = renderlist[i].point.x;
- F32 y = renderlist[i].point.y;
- F32 z = renderlist[i].point.z;
- //Values are between -1 and +1, this ensures all values are positive, since negative values seem to cause issues:
- F32 xscaled = x+1;
- F32 yscaled = y+1;
- F32 zscaled = z+1;
- //convert to spherical coordinates:
- F32 radialdistance_r = sqrt(xscaled*xscaled + yscaled*yscaled + zscaled*zscaled);
- F32 polarangle_theta = mAcos(zscaled / radialdistance_r);//0-PI
- F32 azimuthalangle_phi = mAtan2(yscaled, xscaled); //0-2PI
- //Using Rodrigues rotation forumula, as given here:
- //http://stackoverflow.com/questions/26453951/rotateing-vector-on-plane-in-3d
- Point3F v = Point3F(radialdistance_r, polarangle_theta, azimuthalangle_phi);
- Point3F k = Point3F(0, 1, 0); //rotate on y axix
- F32 theta = 0.0174533;// rotate by 1 degree only for now
- Point3F vRot = v*mCos(theta) + mCross(k, v)*mSin(theta) + k*mDot(k, v)*(1 - mCos(theta));
- Point3F newpos = v * vRot;
- Con::printf("%f %f %f", newpos.x, newpos.y, newpos.z);
Advertisement
Add Comment
Please, Sign In to add comment