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


C++ RotateZ函数代码示例

本文整理汇总了C++中RotateZ函数的典型用法代码示例。如果您正苦于以下问题:C++ RotateZ函数的具体用法?C++ RotateZ怎么用?C++ RotateZ使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RotateZ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tree_trunk

Node* tree_trunk(int number, float radius, float height, mat4 m)
{

    Node *head = new Node[number+1];
    //-------------
    //memory manage
    head->gar=garb;
    garb=head;
    //-------------

    int t_index=0;
    float width = 2.0f * sin( M_PI/ number ) * radius ; // scaled width

    float step = 360.0f/float(number);
    mat4 rec_scal = Scale( height, width,  1.0f ) ; // scale matrix

    head[t_index] = Node( m , blank, NULL, &head[1]); //head

    for(int i=0; i< number-1 ;i++)
    {
        m = RotateZ(step*i)*Translate ( radius * cos(M_PI/number) , -width/2.0f , 0.0f )*RotateY(-90.0) * rec_scal;

        head[i+1] = Node( m, rectangleB, &head[i+2], NULL);
    }
    m = RotateZ(step*(number-1))*Translate ( radius * cos(M_PI/number) , -width/2 , 0.0f )*RotateY(-90.0) * rec_scal;

    head[number] = Node( m, rectangleB, NULL, NULL); // end
    return head;

}
开发者ID:yuejoo,项目名称:opengl_example,代码行数:30,代码来源:main.cpp

示例2: tree_top

Node* tree_top(int number, float radius, float height, mat4 m)
{

    Node *head = new Node[number+1];

    //-------------
    //memory manage
    head->gar=garb;
    garb=head;
    //-------------
    
    int t_index=0;
    float width = 2.0f * sin( M_PI/ number ) * radius ; // scaled width
    float step = 360.0f/float(number); 
    float shift = radius * cos(M_PI/number);  // triangle shift to the  position
    float len = 2* sqrt ( shift*shift + height * height ); // height of triangle
    float cita = atan(height/shift)/M_PI*180.0f;
    mat4 rec_scal = Scale( - len , width,  1.0f ) ; // scale matrix

    head[t_index] = Node( m , blank, NULL, &head[1]); //head

    for(int i=0; i< number-1 ;i++)
    {
        m = RotateZ(step*i)*Translate ( shift , 0.0f , 0.0f )* RotateY(cita) * rec_scal;

        head[i+1] = Node( m, triangleG, &head[i+2], NULL);
    }
    m = RotateZ(step*(number-1))*Translate ( shift , 0.0f , 0.0f )*RotateY(cita) * rec_scal;

    head[number] = Node( m, triangleG, NULL, NULL); // end
    return head;
}
开发者ID:yuejoo,项目名称:opengl_example,代码行数:32,代码来源:main.cpp

示例3: org_scen

Node * org_scen()
{
    
    Node *head = new Node[6];
 
    //-------------
    //memory manage
    head->gar=garb;
    garb=head;
    //-------------    
    mat4 m = Translate(0.0,0.0,0)*RotateZ(45);
    head[0] = Node( m, blank , NULL, &head[1]);
    m = Translate(10,10,0);
    head[1] = Node( m , blank , &head[2], org_house_tree(1.0));
    m = Translate(10.0,-10.0,0)* RotateZ(35);
    head[2] = Node( m , blank , &head[3], org_house_tree(0.5));
    m = Translate(-10.0,10.0,0)* RotateZ(95);
    head[3] = Node( m , blank , &head[4], org_house_tree(1.3));
    m = Translate(-10.0,-10.0,0)* RotateZ(15);
    head[4] = Node( m , blank , &head[5], org_house_tree(0.8));
    m = Translate(0.0,0.0,0)* RotateZ(0);
    head[5] = Node( m , blank , NULL, org_house_tree(0.7));
    
    return head;


}
开发者ID:yuejoo,项目名称:opengl_example,代码行数:27,代码来源:main.cpp

示例4: Translate

void Joint::updateTransform(Animation *animation, int frameCounter, int &channelCounter)
{
	if(numChannels == 6)
	{
		Mat4f temp = Translate(animation->Frames[frameCounter].Tranformations[channelCounter], animation->Frames[frameCounter].Tranformations[channelCounter + 1], animation->Frames[frameCounter].Tranformations[channelCounter + 2]);
		TLocal = temp; 

		////so animations stay in one spot
		//Mat4f temp = Translate(0.0f, animation->Frames[frameCounter].Tranformations[channelCounter + 1], 0.0f);
		//TLocal = temp; 	

		Mat4f rZ = RotateZ(animation->Frames[frameCounter].Tranformations[channelCounter + 3]);	//z
		Mat4f rX = RotateX(animation->Frames[frameCounter].Tranformations[channelCounter + 4]);	//y
		Mat4f rY = RotateY(animation->Frames[frameCounter].Tranformations[channelCounter + 5]);	//x
		RLocal = rZ * rX * rY; //rZ * rY * rX

		channelCounter += 6;
	}
	else if(numChannels == 3)
	{
		Mat4f rZ = RotateZ(animation->Frames[frameCounter].Tranformations[channelCounter]);
		Mat4f rX = RotateX(animation->Frames[frameCounter].Tranformations[channelCounter + 1]);
		Mat4f rY = RotateY(animation->Frames[frameCounter].Tranformations[channelCounter + 2]);
		RLocal = rZ * rX * rY; 

		channelCounter += 3;
	}

	//update all of the childern
	for(unsigned int i = 0; i < this->Children.size(); i++)
	{
		Children[i]->updateTransform(animation, frameCounter, channelCounter);	
	}
}
开发者ID:KrisMaddeaux,项目名称:Telkram,代码行数:34,代码来源:BVH_FileLoader.cpp

示例5: drawBouquet

void drawBouquet(float r, float g, float b)
{
	
	mvstack.push(model_view);
		model_view *= RotateX(-90);
		set_colour(r,g,b);
		drawCone();

		model_view *= RotateX(90);
		model_view *= Translate(0.0f, 2.0f, 0.0f);
		drawFlower();

		mvstack.push(model_view);
			model_view *= RotateZ(25);
			model_view *= Translate(-1.0f, 0.25f, 0.0f);
			drawFlower();
		model_view = mvstack.pop();

		mvstack.push(model_view);
			model_view *= RotateZ(-25);
			model_view *= Translate(1.0f, 0.25f, 0.0f);
			drawFlower();
		model_view = mvstack.pop();
	model_view = mvstack.pop();
}
开发者ID:gulfstreamiv,项目名称:UCLA-CS-Coursework,代码行数:25,代码来源:anim.cpp

示例6: org_house_tree

Node* org_house_tree(float fac1)  // 5
{
    
    Node *head = new Node[6];
 
    //-------------
    //memory manage
    head->gar=garb;
    garb=head;
    //-------------    
    mat4 m = Translate(-3.0,3.0,0)*RotateZ(0);
    head[0] = Node( m, blank , NULL, &head[1]);
    m = Translate(1.5,1.5,0);
    head[1] = Node( m , blank , &head[2], init_tree(0.3*fac1,6.0,0.2,4));
    m = Translate(-3.0,-3.0,0)* RotateZ(45);
    head[2] = Node( m , blank , &head[3], inithouseNode(2.3,2.1*fac1,1.2));
    m = Translate(-3.0,3.0,0)* RotateZ(95);
    head[3] = Node( m , blank , &head[4], init_tree(0.2,5.0,0.4,6*fac1));
    m = Translate(3.0,-3.0,0)* RotateZ(180);
    head[4] = Node( m , blank , &head[5], inithouseNode(2.3*fac1,2.1,3.2));
    m = Translate(-5.0,0.0,0)* RotateZ(0);
    head[5] = Node( m , blank , NULL, inithouseNode(1.3,5.0*fac1,1.2));
    
    return head; 

}
开发者ID:yuejoo,项目名称:opengl_example,代码行数:26,代码来源:main.cpp

示例7: drawFlower

void drawFlower()
{
	float theta;
	mvstack.push(model_view);
	for (int i = 0; i <8; i++){
		
		theta =5*sin(30*DegreesToRadians*TIME);
		model_view *= RotateZ(theta);
		model_view *= Translate(0.0f, 1, 0.0f);
		mvstack.push(model_view);
		model_view *= Scale(1, 2, 1);
		set_colour(0.545f, 0.271f, 0.075f);
		drawCube();
		model_view = mvstack.top();
		mvstack.pop();
		model_view *= Translate(0.0f, 1, 0.0f);
		if (i == 7)
		{
			model_view *= RotateZ(theta);
			model_view *= Translate(0, 2, 0);
			model_view *= Scale(2, 2, 2);
			set_colour(1.0f, 0.0f, 0.0f);
			drawSphere();
		}
	}
	model_view = mvstack.top();
	mvstack.pop();
}
开发者ID:4solo,项目名称:cs174,代码行数:28,代码来源:anim.cpp

示例8: keyboard

void keyboard(unsigned char key, int x, int y) {
	switch(key) {
	case 033: // Esc
	case 'q': 
		exit(EXIT_SUCCESS);
		break;
	case 'w': // Write
		saveState("savestate.rubiks");
		break;
	case 'e': // Edit
		loadState("savestate.rubiks");
		break;
	case 'r': // Reset
		resetRotationMatrix();
		break;

	// Scene rotation with arrow keys
	case 'k':
		rotationMat *= RotateX(ROTATION_FACTOR_KEYBOARD);
		break;
	case 'j':
		rotationMat *= RotateX(-ROTATION_FACTOR_KEYBOARD);
		break;
	case 'l':
		rotationMat *= RotateZ(ROTATION_FACTOR_KEYBOARD);
		break;
	case 'h':
		rotationMat *= RotateZ(-ROTATION_FACTOR_KEYBOARD);
		break;
	
	// Shift + number keys
	case '!': key = 1; break;
	case '@': key = 2; break;
	case '#': key = 3; break;
	case '$': key = 4; break;
	case '%': key = 5; break;
	case '^': key = 6; break;
	case '&': key = 7; break;
	case '*': key = 8; break;
	case '(': key = 9; break;
	}
	if (key <= 9) {
		key--;
		rotateSlice(positions,key/3,key%3,false);
	}
	if (key > '0' && key <='9') {
		int p = key - '1';
		rotateSlice(positions,p/3,p%3,true);
	}
}
开发者ID:williamho,项目名称:rubiks,代码行数:50,代码来源:rubiks.cpp

示例9: Euler2C_One

/*
 * Arguments    : const float euler[3]
 *                float C[9]
 * Return Type  : void
 */
static void Euler2C_One(const float euler[3], float C[9])
{
  float fv3[9];
  float fv4[9];
  float fv5[9];
  float fv6[9];
  int i3;
  int i4;
  int i5;

  /*  if ~exist('rotateOrder','var') || isempty(rotateOrder) */
  /*      rotateOrder = 'ZYX'; */
  /*  end */
  RotateX(euler[2], fv3);
  RotateZ(euler[1], fv4);
  RotateY(euler[0], fv5);
  for (i3 = 0; i3 < 3; i3++) {
    for (i4 = 0; i4 < 3; i4++) {
      fv6[i3 + 3 * i4] = 0.0F;
      for (i5 = 0; i5 < 3; i5++) {
        fv6[i3 + 3 * i4] += fv3[i3 + 3 * i5] * fv4[i5 + 3 * i4];
      }
    }

    for (i4 = 0; i4 < 3; i4++) {
      C[i3 + 3 * i4] = 0.0F;
      for (i5 = 0; i5 < 3; i5++) {
        C[i3 + 3 * i4] += fv6[i3 + 3 * i5] * fv5[i5 + 3 * i4];
      }
    }
  }
}
开发者ID:michille78,项目名称:program_xyz,代码行数:37,代码来源:GenThumbDirection.c

示例10: drawGrass

void drawGrass(void)
{
	mvstack.push(model_view);
		set_colour(0.5f, 1.0f, 0.5f);
		model_view *= RotateZ(grassSway);
		drawGcube();
		model_view *= RotateZ(-grassSway);
		model_view *= Translate(1.0f, 0.0f, 0.0f);
		model_view *= RotateZ(grassSway);
		drawGcube();
		model_view *= RotateZ(-grassSway);
		model_view *= Translate(1.0f, 0.0f, 0.0f);
		model_view *= RotateZ(grassSway);
		drawGcube();
	model_view = mvstack.pop();
}
开发者ID:gulfstreamiv,项目名称:UCLA-CS-Coursework,代码行数:16,代码来源:anim.cpp

示例11: Null

void CRotationMatrix::SetRotation(double angles[3])
{
	Null();
	RotateZ(angles[0]);
	RotateX(angles[1]);
	RotateY(angles[2]);
}
开发者ID:thunderk,项目名称:mandelbulber2,代码行数:7,代码来源:algebra.cpp

示例12: MoveForward

// rotire fata de centru, la o distanta generica 5
void Camera::RotateZCenter (GLfloat Angle)
{
	float distance = 5;
	MoveForward(distance);
	RotateZ(Angle);
	MoveBackward(distance);
}
开发者ID:evelinad,项目名称:Space-Invaders,代码行数:8,代码来源:Camera.cpp

示例13: LoadIdentity

CMatrix44f::CMatrix44f(const float& rotX, const float& rotY, const float& rotZ)
{
	LoadIdentity();
	RotateX(rotX);
	RotateY(rotY);
	RotateZ(rotZ);
}
开发者ID:AlexDiede,项目名称:spring,代码行数:7,代码来源:Matrix44f.cpp

示例14: Resize

//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//	Name        : 初期化
//	Description : 初期化
//	Arguments   : 
//	Returns     : 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
void CFlower::Init(D3DXVECTOR3 pos,D3DXVECTOR3 dir,const LPCTSTR pszFName)
{
	m_kuki = CObject2D::Create(pszFName);
	//m_kuki->Init(D3DXVECTOR3(1,1,0));

	// キャラクターの初期化
	CCharacter::Init();
	Resize(D3DXVECTOR2(FLOWER_SIZE_X,FLOWER_SIZE_Y));
	pos += dir * (FLOWER_SIZE_X / 2);
	Translate(pos);

	m_angle = AngleOf2Vector(pos,D3DXVECTOR3(0,1,0));

	if(m_angle > 0)
		RotateZ((float)m_angle);

	m_lastTime		= CTimer::GetTime();

	if(rand() % 2 == 0)
		m_rotSpd = 3;
	else if(rand() % 2 == 1)
		m_rotSpd = -3;

	// アニメーション初期化
	StartAnimation();

	UVDivision(0, FLOWER_ANIME_SIZE_X, FLOWER_ANIME_SIZE_Y);
}
开发者ID:Kon-Iku,项目名称:graine,代码行数:34,代码来源:Flower.cpp

示例15: Rotate

// rotate about u-axis 
Matrix4D Rotate(const Matrix4D &m,const Vector3D& u, float theta)
{
	float x, y, z,w;
	x = u.x;
	y = u.y;
	z = u.z;

	w=Magnitude(u);
	float ux, uy, uz,ud,xtheta,ytheta;
	ux = x / w;
	uy = y / w;
	uz = z / w;

	ud = pow(pow(uy, 2) + pow(uz, 2), 0.5);
	xtheta = acos(uy / ud);
	ytheta = acos(ud);

	Matrix4D temp;
	temp = Translate(x, y, z)*m;
	temp = RotateX(ytheta)*temp;
	temp = RotateY(ytheta)*temp;
	temp = RotateZ(theta)*temp;
	temp = Inverse(RotateY(ytheta))*temp;
	temp = Inverse(RotateX(xtheta))*temp;
	temp = Inverse(Translate(x, y, z))*temp;

	return temp;

}
开发者ID:Redrock912,项目名称:reboot,代码行数:30,代码来源:transform.cpp


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