Esempio n. 1
0
void R3Matrix:: 
Rotate(const R3Vector& radians)
{
  XRotate(radians.X());
  YRotate(radians.Y());
  ZRotate(radians.Z());
}
Esempio n. 2
0
void R3Point:: 
Rotate(const R3Vector& radians)
{
    // Rotate first around X, then around Y, and finally around Z
    ZRotate(radians.Z());
    YRotate(radians.Y());
    XRotate(radians.X());
}
Esempio n. 3
0
void R4Matrix:: 
Rotate(RNAxis axis, RNAngle radians)
{
    // rotate matrix around an axis counterclockwise
    switch (axis) {
    case RN_XAXIS: 
	XRotate(radians); 
	break;

    case RN_YAXIS: 
	YRotate(radians); 
	break;

    case RN_ZAXIS: 
	ZRotate(radians); 
	break;

    default: 
	RNWarning("Matrix rotation around undefined axis");
	break;
    }
}
Esempio n. 4
0
void R3Matrix:: 
Rotate(int axis, double radians)
{
  // rotate matrix around an axis counterclockwise
  switch (axis) {
  case R3_X: 
    XRotate(radians); 
    break;

  case R3_Y: 
    YRotate(radians); 
    break;

  case R3_Z: 
    ZRotate(radians); 
    break;

  default: 
    fprintf(stderr, "Matrix rotation around undefined axis");
    break;
  }
}
Esempio n. 5
0
void R4Matrix:: 
Rotate(const R3Vector& radians)
{
#if 1
    // Rotate first around X, then around Y, and finally around Z
    ZRotate(radians.Z());
    YRotate(radians.Y());
    XRotate(radians.X());
#else
    // This is faster way to do same thing (not tested)
    R4Matrix rotation(
      cos(radians.Y())*cos(radians.Z()),  
      sin(radians.X())*sin(radians.Y())*cos(radians.Z()) - cos(radians.X())*sin(radians.Z()), 
      cos(radians.X())*sin(radians.Y())*cos(radians.Z()) + sin(radians.X())*sin(radians.Z()), 0,
      cos(radians.Y())*sin(radians.Z()),
      sin(radians.X())*sin(radians.Y())*sin(radians.Z()) + cos(radians.X())*cos(radians.Z()),
      cos(radians.X())*sin(radians.Y())*sin(radians.Z()) - sin(radians.X())*cos(radians.Z()), 0,
      -sin(radians.Y()), 
      cos(radians.Y())*sin(radians.X()),
      cos(radians.X())*cos(radians.Y()), 0,
      0, 0, 0, 1);
    *this = rotation * (*this);
#endif
}
void Tacho::draw(REAL Revs)
{
	static REAL Step = -PI/6;
	//draw the frame:
	if (CompiledList != 0)
		glCallList(CompiledList);
	else
	{
		//CompiledList = glGenLists(1);
		//glNewList(CompiledList, GL_COMPILE);

		int i;
		Point3D IntPt(0,-R_INT,0), ExtPt(0,-R_EXT,0);
		Hgl::SetColor(Color(250,130,0));
		ZRotate(IntPt,Step*(1+(MyRedLine/1000)));
		ZRotate(ExtPt,Step*(1+(MyRedLine/1000)));
		glBegin(GL_QUADS);
		for (i=0 ; i<=4 ; i++)
		{
			Hgl::Vertex(IntPt);
			Hgl::Vertex(ExtPt);
			ZRotate(IntPt,Step/3);
			ZRotate(ExtPt,Step/3);
			Hgl::Vertex(ExtPt);
			Hgl::Vertex(IntPt);
			if (i==1) Hgl::SetColor(Color(255,0,0));
		}
		glEnd();

		Hgl::SetColor(Color(255,255,255));
		glLineWidth(2);
		IntPt = Point3D(0,-R_INT,0);
		ExtPt = Point3D(0,-R_EXT,0);
		ZRotate(IntPt,Step);
		ZRotate(ExtPt,Step);
		glBegin(GL_LINES);
		for (i=0 ; i<=(MyRedLine/1000)+2 ; i++)
		{
			Hgl::Vertex(ExtPt);
			Hgl::Vertex(IntPt);
			ZRotate(IntPt,Step);
			ZRotate(ExtPt,Step);
		}
		glEnd();

		//glEndList();
	}
	//draw the needle:
	Point3D TipPt(0,-NEEDLE_LEN_F,0);
	Point3D BackPtR(-NEEDLE_WIDTH,NEEDLE_LEN_B,0);
	Point3D BackPtL(NEEDLE_WIDTH,NEEDLE_LEN_B,0);
	REAL Angle = Step*(1+min(Revs,(MyRedLine+1000))/1000);
	ZRotate(TipPt,Angle);
	ZRotate(BackPtL,Angle);
	ZRotate(BackPtR,Angle);

	Hgl::SetColor(Color(255,0,0));
	glBegin(GL_TRIANGLES);
	Hgl::Vertex(TipPt);
	Hgl::Vertex(BackPtR);
	Hgl::Vertex(BackPtL);
	glEnd();
	Hgl::SetColor(Color(255,255,255));
}