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


C++ Plane::GetX方法代码示例

本文整理汇总了C++中Plane::GetX方法的典型用法代码示例。如果您正苦于以下问题:C++ Plane::GetX方法的具体用法?C++ Plane::GetX怎么用?C++ Plane::GetX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plane的用法示例。


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

示例1: GetCMatrix

	bool Restraint::GetCMatrix(const Plane structureOrientation, arma::mat & CN)
	{
		// Check if restraint plane differs from global plane
		if (structureOrientation.CompareTo(this->_orientation))
			return false;

		// If different
		CN = arma::mat(6, 6, arma::fill::zeros);

		Vector3d drX = this->GetXDir();
		Vector3d drY = this->GetYDir();
		Vector3d drZ = this->GetZDir();

		Vector3d strX = structureOrientation.GetX();
		Vector3d strY = structureOrientation.GetY();
		Vector3d strZ = structureOrientation.GetZ();

		double nxx = drX.DotProduct(strX);
		double nxy = drY.DotProduct(strY);
		double nxz = drZ.DotProduct(strZ);

		double nyx = drX.DotProduct(strX);
		double nyy = drY.DotProduct(strY);
		double nyz = drZ.DotProduct(strZ);

		double nzx = drX.DotProduct(strX);
		double nzy = drY.DotProduct(strY);
		double nzz = drZ.DotProduct(strZ);

		// Two times for same transformations for translations (1) and rotations(2)
		for (int i = 0; i < 2; i++)
		{
			CN[0 + i * 3, 0 + i * 3] = nxx;
			CN[0 + i * 3, 1 + i * 3] = nxy;
			CN[0 + i * 3, 2 + i * 3] = nxz;

			CN[1 + i * 3, 0 + i * 3] = nyx;
			CN[1 + i * 3, 1 + i * 3] = nyy;
			CN[1 + i * 3, 2 + i * 3] = nyz;

			CN[2 + i * 3, 0 + i * 3] = nyx;
			CN[2 + i * 3, 1 + i * 3] = nyy;
			CN[2 + i * 3, 2 + i * 3] = nyz;
		}

		return true;
	}
开发者ID:IsakNaslund,项目名称:MasterThesis,代码行数:47,代码来源:Restraint.cpp

示例2: BulletMove


//.........这里部分代码省略.........
		}
		else if (m_iStep == STEP_3)
		{
			m_iSpeed += m_iAcceleration;
			if (m_iSpeed >= m_iFinalSpeed)
			{
				m_iSpeed = m_iFinalSpeed;
			}
		}

		radian = m_iDirection/180 * PI;

		SetX(m_iX + m_iSpeed*sin(radian));
		SetY(m_iY + m_iSpeed*cos(radian));
		break;

	case 3:	//×·×Ùµ¼µ¯
		switch (m_iStep)
		{
		case STEP_1:
			m_iAngle = m_iDirection/180 * PI;

			SetX(m_iX + m_iSpeed*sin(m_iAngle));
			SetY(m_iY + m_iSpeed*cos(m_iAngle));

			if (g_Time - m_Time > 500)
			{
				m_iStep = STEP_2;
			}
			break;

		case STEP_2:
			{
				vector<Plane *>* tempPlanes = g_Manager.GetPlaneVector();

				for (int i=1; i<(int)tempPlanes->size(); i++)
				{
					if ((*tempPlanes)[i])
					{
						m_iTarget = i;
						break;
					}
				}

				m_iStep = STEP_3;
			}
			break;

		case STEP_3:
			if (m_iTarget != -1)
			{
				Plane *target = (*g_Manager.GetPlaneVector())[m_iTarget];
				if (target)
				{
					m_iDesX = target->GetX();
					m_iDesY = target->GetY();

					m_iAngle = atan((double)(m_iDesX-m_iX)/(double)(m_iDesY-m_iY));
					m_iDirection = m_iAngle*180/PI;

					if (m_iDesY > m_iY)
					{
						SetX(m_iX + m_iSpeed*sin(m_iAngle));
						SetY(m_iY + m_iSpeed*cos(m_iAngle));
					}
					else if(m_iDesY < m_iY)
					{
						SetX(m_iX - (int)(m_iSpeed*sin(m_iAngle)));
						SetY(m_iY - (int)(m_iSpeed*cos(m_iAngle)));
					}
					else
					{
						if (m_iDesX > m_iX)
						{
							SetX(m_iX+m_iSpeed);
						}
						else
						{
							SetX(m_iX-m_iSpeed);
						}
					}
				}
				else
				{
					m_iTarget = -1;
				}	
			}
			else
			{
				m_iAngle = m_iDirection/180 * PI;

				SetX(m_iX + m_iSpeed*sin(m_iAngle));
				SetY(m_iY + m_iSpeed*cos(m_iAngle));
			}
			break;
		}
		break;
	}

}
开发者ID:peitaosu,项目名称:Plane-Game-with-Leap,代码行数:101,代码来源:Bullet.cpp

示例3: UpdatePlane

void PlaneGuard::UpdatePlane()
{
	Plane *target = (*g_Manager.GetPlaneVector())[m_Target];

	if (!target)
	{
		m_iState = P_DISAPPEAR;
		return;
	}

	if (m_bMoveable)
	{
		m_iDirection += m_iSpeed;
		if (m_iDirection >= 360)
		{
			m_iDirection -= 360;
		}
		m_Angle = m_iDirection/180 * PI;

		SetX(target->GetX() + (int)(m_Distance*sin(m_Angle)));
		SetY(target->GetY() + (int)(m_Distance*cos(m_Angle)));

		//¸üз¢ÉäÆ÷µÄλÖÃ
		for (int i=0; i<(int)m_vShooterGroup.size(); i++)
		{
			for (int j=0; j<(int)m_vShooterGroup[i].size(); j++)
			{
				m_vShooterGroup[i][j]->SetPos(m_iX, m_iY);
			}
		}
	}

	//·¢Éä
	m_bFireOver = true;
	vector<Shooter*> *pShooters = &m_vShooterGroup[m_iNowShooterGroup];
	for (int i=0; i<(int)pShooters->size(); i++)
	{
		if (m_bFireCommand)
		{
			(*pShooters)[i]->SetCommand(true);
			m_bFireOver &= (*pShooters)[i]->Fire(false); 
		}
	}

	if (m_bFireOver)
	{
		m_iNowShooterGroup++;
		if (m_iNowShooterGroup >= (int)pShooters->size())
		{
			m_iNowShooterGroup = 0;
		}

		for (int i=0; i<(int)pShooters->size(); i++)
		{
			(*pShooters)[i]->SetCommand(false);
			(*pShooters)[i]->Reload(); 
		}
	}

	if (m_bImpactable)
	{
		//Åöײ²¿·Ö
	}
}
开发者ID:peitaosu,项目名称:Plane-Game-with-Leap,代码行数:64,代码来源:PlaneGuard.cpp


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