コード例 #1
0
ファイル: Surfaces.cpp プロジェクト: abcweizhuo/Test3
double CSurface2D::operator()(double X)
  {
  if (!m_UseSurface)
    return m_fnY(X);

  long Ix;
  double Fx;
  X2Map(X, Ix, Fx);

  ASSERT(Ix<m_Elements.GetSize());
//  int iFx=(int)floor(Fx*m_iDX);
//  if (m_DoSmoothing && (iFx==0 || iFx==(m_iDX-1))
  if (m_DoSmoothing)
    {
    long IxM, IxP;
    double FxM, FxP;
    GetDX(Ix, Fx, m_DX, m_nDivs, IxM, FxM, IxP, FxP);
    CSurface2DElement &EM=GetElement(IxM);
    CSurface2DElement &EP=GetElement(IxP);

    //if (m_ForceFn) // Force Use Of Function
    //  return m_fnY(X);
  
    return m_fnYO(0.5*(EM(FxM)+EP(FxP)));
    }

  CSurface2DElement &E=GetElement(Ix);
  
  //if (m_ForceFn) // Force Use Of Function
  //  return m_fnY(X);
  return m_fnYO(E(Fx));
  };
コード例 #2
0
void Rat::Draw(){
	//glpushmatrix
	//gltranslated(x, y, 0)
	//glrotated(mrotation, 0, 0, 1)
	//draw rat at origin
	double x1, y1, x2, y2;
	this->mPosition.zPos = (sin(clock() * 0.001)+1.4)/4;
	//rat is a square that is .4 world units width and height
	//to get bottom left corner for drawing, subtract 
	x1 = this->mPosition.xPos - this->mSize / 2;
	y1 = this->mPosition.yPos - this->mSize / 2;
	x2 = x1 + this->mSize;
	y2 = y1 + this->mSize;	
	glPushMatrix();
	glTranslated(this->mPosition.xPos, this->mPosition.yPos, this->mPosition.zPos);
	glRotated(this->mRotation, 0, 0, 1);
	glScalef(0.5, 0.5, 0.5);
	glColor3ub(255,45,75);
	glutSolidCube(0.5);
	//Draw::Indicator(this->mPosition.xPos, this->mPosition.yPos, 0.4);
	glPopMatrix();

	glColor3ub(128, 128, 128);
	glPushMatrix();

	const float dirX = GetDX() * 2.3;
	const float dirY = GetDY() * 2.3;

	glTranslated(this->mPosition.xPos - dirX, this->mPosition.yPos - dirY, this->mPosition.zPos);
	glRotated(this->mRotation, 0, 0, 1);
	glScaled(1.2, .6, .7);
	glutSolidCube(0.5);
	glPopMatrix();
	/*
	glRotated(this->mRotation, 0, 0, 1);
	glTranslated(this->mPosition.xPos, this->mPosition.yPos, 0.1);
	glScalef(0.5, 0.5, 0.5);
	glColor3ub(0, 0, 0);
	glutSolidCube(0.5);
	glPopMatrix();
	*/
}