本文整理汇总了C++中ToRadian函数的典型用法代码示例。如果您正苦于以下问题:C++ ToRadian函数的具体用法?C++ ToRadian怎么用?C++ ToRadian使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToRadian函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToRadian
void Pipeline::InitRotateTransform(Matrix4f& m) const
{
Matrix4f rx, ry, rz;
const float x = ToRadian(m_rotateInfo.x);
const float y = ToRadian(m_rotateInfo.y);
const float z = ToRadian(m_rotateInfo.z);
rx.m[0][0] = 1.0f; rx.m[0][1] = 0.0f ; rx.m[0][2] = 0.0f ; rx.m[0][3] = 0.0f;
rx.m[1][0] = 0.0f; rx.m[1][1] = cosf(x); rx.m[1][2] = -sinf(x); rx.m[1][3] = 0.0f;
rx.m[2][0] = 0.0f; rx.m[2][1] = sinf(x); rx.m[2][2] = cosf(x) ; rx.m[2][3] = 0.0f;
rx.m[3][0] = 0.0f; rx.m[3][1] = 0.0f ; rx.m[3][2] = 0.0f ; rx.m[3][3] = 1.0f;
ry.m[0][0] = cosf(y); ry.m[0][1] = 0.0f; ry.m[0][2] = -sinf(y); ry.m[0][3] = 0.0f;
ry.m[1][0] = 0.0f ; ry.m[1][1] = 1.0f; ry.m[1][2] = 0.0f ; ry.m[1][3] = 0.0f;
ry.m[2][0] = sinf(y); ry.m[2][1] = 0.0f; ry.m[2][2] = cosf(y) ; ry.m[2][3] = 0.0f;
ry.m[3][0] = 0.0f ; ry.m[3][1] = 0.0f; ry.m[3][2] = 0.0f ; ry.m[3][3] = 1.0f;
rz.m[0][0] = cosf(z); rz.m[0][1] = -sinf(z); rz.m[0][2] = 0.0f; rz.m[0][3] = 0.0f;
rz.m[1][0] = sinf(z); rz.m[1][1] = cosf(z) ; rz.m[1][2] = 0.0f; rz.m[1][3] = 0.0f;
rz.m[2][0] = 0.0f ; rz.m[2][1] = 0.0f ; rz.m[2][2] = 1.0f; rz.m[2][3] = 0.0f;
rz.m[3][0] = 0.0f ; rz.m[3][1] = 0.0f ; rz.m[3][2] = 0.0f; rz.m[3][3] = 1.0f;
m = rz * ry * rx;
}
示例2: Vector3
Vector3 FPMovement::movementFP(Vector3 dir)
{
Vector3 direction = Vector3(0,0,0);
//D3DXVec3Transform(&start,&lightSource.dir,&rotateX)
if(GetAsyncKeyState('W') & 0x8000)
direction = Vector3(dir.x,0,dir.z);
if(GetAsyncKeyState('A') & 0x8000)
{
Matrix r;
RotateY(&r,ToRadian(-90.0f));
Vector4 d;
D3DXVec3Transform(&d,&dir,&r);
direction = Vector3(d.x,0,d.z);
}
if(GetAsyncKeyState('S') & 0x8000)
direction = Vector3(dir.x,0,dir.z)*-1;
if(GetAsyncKeyState('D') & 0x8000)
{
Matrix r;
RotateY(&r,ToRadian(90.0f));
Vector4 d;
D3DXVec3Transform(&d,&dir,&r);
direction = Vector3(d.x,0,d.z);
}
if(direction != VectorZero)
Normalize(&direction, &direction);
return direction;
}
示例3: ToRadian
void Node::getObjectRotation(Matrix4f& dst)
{
float angle;
Matrix4f mX, mY, mZ;
if(this->_rotation.getX()) {
//rotate around X
angle = ToRadian(_rotation.getX());
mX.m[1][1] = cos(angle);
mX.m[1][2] = -sin(angle);
mX.m[2][1] = sin(angle);
mX.m[2][2] = cos(angle);
}
if(this->_rotation.getY()) {
//rotate around y
angle = ToRadian(_rotation.getY());
mY.m[0][0] = cos(angle);
mY.m[0][2] = sin(angle);
mY.m[2][0] = -sin(angle);
mY.m[2][2] = cos(angle);
}
if(this->_rotation.getZ()) {
//rotate around z
angle = ToRadian(_rotation.getZ());
mZ.m[0][0] = cos(angle);
mZ.m[0][1] = -sin(angle);
mZ.m[1][0] = sin(angle);
mZ.m[1][1] = cos(angle);
}
dst = mX * mY * mZ;
}
示例4: printf
void Vector3f::Rotate(float Angle, const Vector3f& Axis)
{
/*printf("\n");
printf("Angle %f\n", Angle);
printf("Before %f %f %f\n", x, y, z);*/
const float SinHalfAngle = sinf(ToRadian(Angle/2));
const float CosHalfAngle = cosf(ToRadian(Angle/2));
//printf("sin %f cos %f\n", SinHalfAngle, CosHalfAngle);
const float Rx = Axis.x * SinHalfAngle;
const float Ry = Axis.y * SinHalfAngle;
const float Rz = Axis.z * SinHalfAngle;
const float Rw = CosHalfAngle;
//printf("Rotation quaternion %f %f %f %f\n", Rx, Ry, Rz, Rw);
Quaternion RotationQ(Rx, Ry, Rz, Rw);
Quaternion ConjugateQ = RotationQ.Conjugate();
ConjugateQ.Normalize();
//printf("Conjugate %f %f %f %f\n", ConjugateQ.x, ConjugateQ.y, ConjugateQ.z, ConjugateQ.w);
Quaternion W = RotationQ * (*this);
// printf("Q * View: %f %f %f %f\n", W.x, W.y, W.z, W.w);
W *= ConjugateQ;
// printf("Q * View * Conjugate: %f %f %f %f\n", W.x, W.y, W.z, W.w);
x = W.x;
y = W.y;
z = W.z;
//printf("After %f %f %f\n", x, y, z);
}
示例5: ToRadian
void Pipeline::InitRotateTrans(Matrix4f& mat)
{
Matrix4f rx,ry,rz;
const float x = ToRadian(m_rotation.x);
const float y = ToRadian(m_rotation.y);
const float z = ToRadian(m_rotation.z);
rx.mat[0][0] = 1.0f;rx.mat[0][1] = 0.0f;rx.mat[0][2] = 0.0f;rx.mat[0][3] = 0.0f;
rx.mat[1][0] = 0.0f;rx.mat[1][1] = cosf(x);rx.mat[1][2] = -sinf(x);rx.mat[1][3] = 0.0f;
rx.mat[2][0] = 0.0f;rx.mat[2][1] = sinf(x);rx.mat[2][2] = cosf(x);rx.mat[2][3] = 0.0f;
rx.mat[3][0] = 0.0f;rx.mat[3][1] = 0.0f;rx.mat[3][2] = 0.0f;rx.mat[3][3] = 1.0f;
ry.mat[0][0] = cosf(y);ry.mat[0][1] = 0.0f;ry.mat[0][2] = -sinf(y);ry.mat[0][3] = 0.0f;
ry.mat[1][0] = 0.0f;ry.mat[1][1] = 1.0f;ry.mat[1][2] = 0.0f;ry.mat[1][3] = 0.0f;
ry.mat[2][0] = sinf(y);ry.mat[2][1] = 0.0f;ry.mat[2][2] = cosf(y);ry.mat[2][3] = 0.0f;
ry.mat[3][0] = 0.0f;ry.mat[3][1] = 0.0f;ry.mat[3][2] = 0.0f;ry.mat[3][3] = 1.0f;
rz.mat[0][0] = cosf(z);rz.mat[0][1] = -sinf(z);rz.mat[0][2] = 0.0f;rz.mat[0][3] = 0.0f;
rz.mat[1][0] = sinf(z);rz.mat[1][1] = cos(z);rz.mat[1][2] = 0.0f;rz.mat[1][3] = 0.0f;
rz.mat[2][0] = 0.0f;rz.mat[2][1] = 0.0f;rz.mat[2][2] = 1.0f;rz.mat[2][3] = 0.0f;
rz.mat[3][0] = 0.0f;rz.mat[3][1] = 0.0f;rz.mat[3][2] = 0.0f;rz.mat[3][3] = 1.0f;
mat = rz * ry * rx;
}
示例6: getIdentity
Matrix4f Camera::getRotationM()
{
Matrix4f xRot, yRot, zRot, m_identity, result;
m_identity = getIdentity();
/* get the rotation radians about each axis */
const float xRads = ToRadian(xRotation);
const float yRads = ToRadian(yRotation);
const float zRads = ToRadian(zRotation);
/* rotate around the x axis */
copyMatrix(xRot, m_identity);
xRot.m[1][1] = cosf(xRads); xRot.m[1][2] = -sinf(xRads);
xRot.m[2][1] = sinf(xRads); xRot.m[2][2] = cosf(xRads);
/* rotate around the y axis */
copyMatrix(yRot, m_identity);
yRot.m[0][0] = cosf(yRads); yRot.m[0][2] = -sinf(yRads);
yRot.m[2][0] = sinf(yRads); yRot.m[2][2] = cosf(yRads);
/* rotate around the z axis*/
copyMatrix(zRot, m_identity);
zRot.m[0][0] = cosf(zRads); zRot.m[0][1] = -sinf(zRads);
zRot.m[1][0] = sinf(zRads); zRot.m[1][1] = cosf(zRads);
result = (yRot * xRot * zRot);
return result;
}
示例7: ToRadian
void Matrix4f::InitRotateTransform(float RotateX, float RotateY, float RotateZ)
{
Matrix4f rx, ry, rz;
const float x = ToRadian(RotateX);
const float y = ToRadian(RotateY);
const float z = ToRadian(RotateZ);
rx.m[0][0] = 1.0f; rx.m[0][1] = 0.0f ; rx.m[0][2] = 0.0f ; rx.m[0][3] = 0.0f;
rx.m[1][0] = 0.0f; rx.m[1][1] = cosf(x); rx.m[1][2] = -sinf(x); rx.m[1][3] = 0.0f;
rx.m[2][0] = 0.0f; rx.m[2][1] = sinf(x); rx.m[2][2] = cosf(x) ; rx.m[2][3] = 0.0f;
rx.m[3][0] = 0.0f; rx.m[3][1] = 0.0f ; rx.m[3][2] = 0.0f ; rx.m[3][3] = 1.0f;
ry.m[0][0] = cosf(y); ry.m[0][1] = 0.0f; ry.m[0][2] = -sinf(y); ry.m[0][3] = 0.0f;
ry.m[1][0] = 0.0f ; ry.m[1][1] = 1.0f; ry.m[1][2] = 0.0f ; ry.m[1][3] = 0.0f;
ry.m[2][0] = sinf(y); ry.m[2][1] = 0.0f; ry.m[2][2] = cosf(y) ; ry.m[2][3] = 0.0f;
ry.m[3][0] = 0.0f ; ry.m[3][1] = 0.0f; ry.m[3][2] = 0.0f ; ry.m[3][3] = 1.0f;
rz.m[0][0] = cosf(z); rz.m[0][1] = -sinf(z); rz.m[0][2] = 0.0f; rz.m[0][3] = 0.0f;
rz.m[1][0] = sinf(z); rz.m[1][1] = cosf(z) ; rz.m[1][2] = 0.0f; rz.m[1][3] = 0.0f;
rz.m[2][0] = 0.0f ; rz.m[2][1] = 0.0f ; rz.m[2][2] = 1.0f; rz.m[2][3] = 0.0f;
rz.m[3][0] = 0.0f ; rz.m[3][1] = 0.0f ; rz.m[3][2] = 0.0f; rz.m[3][3] = 1.0f;
*this = rz * ry * rx;
}
示例8: ToRadian
void Matrix4f::setRotateTransform(const Vector3f& rotate)
{
Matrix4f xy, xz, yz;
const float x = ToRadian(rotate.x);
const float y = ToRadian(rotate.y);
const float z = ToRadian(rotate.z);
xy.setMatrix(cosf(z), -sinf(z), 0.0f, 0.0f,
sinf(z), cosf(z), 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
xz.setMatrix(cosf(y), 0.0f, -sinf(y), 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
sinf(y), 0.0f, cosf(y), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
yz.setMatrix(1.0f, 0.0f, 0.0f, 0.0f,
0.0f, cosf(x), sinf(x), 0.0f,
0.0f, -sinf(x), cosf(x), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
*this = xy * xz * yz;
}
示例9: sinf
void Vector3f::rotate(float angle, Vector3f axis)
{
const float sinHalfAngle = sinf(ToRadian(angle/2));
const float cosHalfAngle = cosf(ToRadian(angle/2));
Quaternion rot(axis.getX() * sinHalfAngle, axis.getY() * sinHalfAngle, axis.getZ() * sinHalfAngle, cosHalfAngle);
Quaternion conj = rot.Conjugate();
Quaternion W = rot * (*this) * conj;
x = W.getX();
y = W.getY();
z = W.getZ();
}
示例10: SetRotation
bool CTransform::SetRotation(int rotation)
{
if (m_rotation != rotation)
{
m_rotation = rotation;
GraphTypes::REAL radians=ToRadian(m_rotation);
GraphTypes::REAL cosinus=cos(radians);
GraphTypes::REAL sinus=sin(radians);
mR11=cosinus;
mR12=-sinus;
mR21=sinus;
mR22=cosinus;
miR11=cosinus;
miR12=sinus;
miR21=-sinus;
miR22=cosinus;
MakeComposite();
return true;
}
return false;
}
示例11: ToRadian
Matrix3 Matrix3::MakeRotate(float angle, const Vector3 &a) {
Matrix3 m;
angle = ToRadian(angle);
float ct = Cos(angle);
float st = Sin(angle);
float x2 = a.x * a.x;
float y2 = a.y * a.y;
float z2 = a.z * a.z;
float sx = st * a.x;
float sy = st * a.y;
float sz = st * a.z;
float xy = a.x * a.y;
float xz = a.x * a.z;
float yz = a.y * a.z;
float omct = 1.0f - ct;
m(0,0) = x2 + (1 - x2) * ct;
m(1,0) = xy * omct + sz;
m(2,0) = xz * omct - sy;
m(0,1) = xy * omct - sz;
m(1,1) = y2 + (1 - y2) * ct;
m(2,1) = yz * omct + sx;
m(0,2) = xz * omct + sy;
m(1,2) = yz * omct - sx;
m(2,2) = z2 + (1 - z2) * ct;
return m;
}
示例12: tanf
Matrix44f Pipeline::GetProjLookAt()
{
const float ar = m_OpenGL->GetScreenWidth() / m_OpenGL->GetScreenHeight();
const float zNear = fNear;
const float zFar = fFar;
const float zRange = zNear - zFar;
const float tanHalfFOV = tanf(ToRadian(fFOV / 2.0));
Matrix44f m;
m[0] = 1.0f / (tanHalfFOV * ar);
m[1] = 0.0f;
m[2] = 0.0f;
m[3] = 0.0f;
m[4] = 0.0f;
m[5] = 1.0f / tanHalfFOV;
m[6] = 0.0f;
m[7] = 0.0f;
m[8] = 0.0f;
m[9] = 0.0f;
m[10] = (-zNear - zFar) / zRange;
m[11] = 2.0f * zFar * zNear / zRange;
m[12] = 0.0f;
m[13] = 0.0f;
m[14] = 1.0f;
m[15] = 0.0f;
return m;
}
示例13: tanf
void Matrix4f::InitPersProjTransform( float FOV, float Width, float Height, float zNear, float zFar )
{
const float ar = Width / Height;
const float zRange = zNear - zFar;
const float tanHalfFOV = tanf( ToRadian( FOV / 2.0f ) );
m[0][0] = 1.0f / ( tanHalfFOV * ar );
m[0][1] = 0.0f;
m[0][2] = 0.0f;
m[0][3] = 0.0;
m[1][0] = 0.0f;
m[1][1] = 1.0f / tanHalfFOV;
m[1][2] = 0.0f;
m[1][3] = 0.0;
m[2][0] = 0.0f;
m[2][1] = 0.0f;
m[2][2] = ( -zNear - zFar ) / zRange;
m[2][3] = 2.0f * zFar*zNear / zRange;
m[3][0] = 0.0f;
m[3][1] = 0.0f;
m[3][2] = 1.0f;
m[3][3] = 0.0;
}
示例14: rotateZ
point3D rotateZ(point3D p1, float angle) {
float radangle = ToRadian(angle);
point3D newPoint(cos(radangle)*p1.x + -sin(radangle)*p1.y + 0*p1.z,
sin(radangle)*p1.x + cos(radangle)*p1.y + 0*p1.z ,
0*p1.x + 0*p1.y + 1*p1.z);
return newPoint;
}
示例15: AJ2Radian
double AJ2Radian(const cValueAvionJaune & aVal)
{
return ToRadian
(
aVal.value(),
AJStr2UAng(aVal.unit())
);
}