三分钟做网站,wordpress调用大全,做冰饮视频网站,软件开发外包服务公司spherical coordinate 和cartesian坐标的转换#xff0c; 个人认为在控制camera的时候最为有用#xff0c;比如CS中的操作方式#xff0c; 鼠标负责方向的改变#xff0c;其恰恰就是球形坐标的改变。而camera的位置改变就是cartesian的改变#xff0c;所以这两者的转换就必… spherical coordinate 和cartesian坐标的转换 个人认为在控制camera的时候最为有用比如CS中的操作方式 鼠标负责方向的改变其恰恰就是球形坐标的改变。而camera的位置改变就是cartesian的改变所以这两者的转换就必不可少了。 以下是基本的数学公式非常简单。Thus, we can convert from spherical to Cartesian coordinates by We convert from Cartesian to spherical coordinates by 我的代码比较烂不要见笑, 没什么注释比较简单大家应该可以看懂://_horizon, _vertical是球形坐标的改变大小 void AO_Camera::moveRatate( float _horizon, float _vertical ) { float r, s, thi, theta, x, y, z; x m_forwardVector.x; y m_forwardVector.y; z m_forwardVector.z; r D3DXVec3Length( m_forwardVector); s D3DXVec3Length( D3DXVECTOR3( x, 0.0f, z) ); thi acos( y / r ); //限制theta的改变范围if ( x 0 ) { theta PI - (float)asinf( z / s ); } else { theta (float)asinf( z / s ); } thi thi _vertical; if ( thi PRECISION ) { thi PRECISION; } else if( thi PI - PRECISION ) { thi PI - PRECISION; } theta theta - _horizon; m_forwardVector.x r * sin( thi ) * cos( theta ); m_forwardVector.z r * sin( thi ) * sin( theta ); m_forwardVector.y r * cos( thi ); m_LookAt m_EyePos m_forwardVector; } 作者 chiyuwang 转载于:https://www.cnblogs.com/chiyuwang/archive/2006/09/04/494676.html