当前位置: 首页>>代码示例>>C++>>正文


C++ ToRadian函数代码示例

本文整理汇总了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;
}
开发者ID:rue-ryuzaki,项目名称:Visual-OpenGL,代码行数:25,代码来源:pipeline.cpp

示例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;
}
开发者ID:oliver-spryn,项目名称:depth-first-survival,代码行数:30,代码来源:FPMovement.cpp

示例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;
}
开发者ID:FabrizioPerria,项目名称:OpenGL,代码行数:32,代码来源:Node.cpp

示例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);
}
开发者ID:emeiri,项目名称:Colossus,代码行数:33,代码来源:colossus_math.cpp

示例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;
}
开发者ID:redknotmiaoyuqiao,项目名称:MyOpenGL,代码行数:25,代码来源:Pipeline.cpp

示例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;
}
开发者ID:Terhands,项目名称:485Project,代码行数:29,代码来源:camera.cpp

示例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;
}
开发者ID:c14006078,项目名称:opengl,代码行数:25,代码来源:math_3d.cpp

示例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;
}
开发者ID:tharkum,项目名称:opengl-demo,代码行数:25,代码来源:Matrix.cpp

示例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();
}
开发者ID:FabrizioPerria,项目名称:OpenGL,代码行数:13,代码来源:math_3d.cpp

示例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;
}
开发者ID:dehilsterlexis,项目名称:eclide-1,代码行数:25,代码来源:Transform.cpp

示例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;
 }
开发者ID:gatgui,项目名称:gmath,代码行数:26,代码来源:matrix.cpp

示例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;
}
开发者ID:Aderos,项目名称:Dark-Raven-Engine,代码行数:32,代码来源:Pipeline.cpp

示例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;
}
开发者ID:SpecBlow,项目名称:LearnGL,代码行数:26,代码来源:math_3d.cpp

示例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;
}
开发者ID:Abysice,项目名称:renderer,代码行数:7,代码来源:mathlib3d.cpp

示例15: AJ2Radian

double AJ2Radian(const cValueAvionJaune & aVal)
{
   return ToRadian
          (
              aVal.value(),
              AJStr2UAng(aVal.unit())
          );
}
开发者ID:xialang2012,项目名称:micmac-archeos,代码行数:8,代码来源:transfo_xml_phgr2.cpp


注:本文中的ToRadian函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。