Guest User

Untitled

a guest
Aug 30th, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1.         F32 x = renderlist[i].point.x;
  2.         F32 y = renderlist[i].point.y;
  3.         F32 z = renderlist[i].point.z;
  4.  
  5.         //Values are between -1 and +1, this ensures all values are positive, since negative values seem to cause issues:
  6.  
  7.         F32 xscaled = x+1;
  8.         F32 yscaled = y+1;
  9.         F32 zscaled = z+1;
  10.  
  11.         //convert to spherical coordinates:
  12.         F32 radialdistance_r = sqrt(xscaled*xscaled + yscaled*yscaled + zscaled*zscaled);
  13.         F32 polarangle_theta = mAcos(zscaled / radialdistance_r);//0-PI
  14.         F32 azimuthalangle_phi = mAtan2(yscaled, xscaled); //0-2PI
  15.  
  16.         //Using Rodrigues rotation forumula, as given here:
  17.         //http://stackoverflow.com/questions/26453951/rotateing-vector-on-plane-in-3d
  18.  
  19.         Point3F v = Point3F(radialdistance_r, polarangle_theta, azimuthalangle_phi);
  20.         Point3F k = Point3F(0, 1, 0); //rotate on y axix
  21.         F32 theta = 0.0174533;// rotate by 1 degree only for now
  22.  
  23.         Point3F vRot = v*mCos(theta) + mCross(k, v)*mSin(theta) + k*mDot(k, v)*(1 - mCos(theta));
  24.  
  25.         Point3F newpos = v * vRot;
  26.  
  27.         Con::printf("%f %f %f",  newpos.x, newpos.y, newpos.z);
Advertisement
Add Comment
Please, Sign In to add comment