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


C++ Vec::getX方法代码示例

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


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

示例1: dotProd

GLdouble dotProd(const Vec &one, const Vec &two){
	GLdouble x = (one.getX() * two.getX());
	GLdouble y = (one.getY() * two.getY());
	GLdouble z = (one.getZ() * two.getZ());

	return (x + y + z);
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:7,代码来源:collision.cpp

示例2: MultiplyVectorFromLeft

/* Multiplication vector and matrix. (vec * *this)
 * ARGUMENTS:
 * - vector to multiply from right
 *     Vec &v;  
 * RETURNS:
 * - result vector
 *     Vec;
 */
Vec Matrix::MultiplyVectorFromLeft( Vec &v )
{  
  Vec res = Vec(v.getX() * M[0][0] + v.getY() * M[0][1] + v.getZ() * M[0][2] + M[0][3],
  	            v.getX() * M[1][0] + v.getY() * M[1][1] + v.getZ() * M[1][2] + M[1][3],
	              v.getX() * M[2][0] + v.getY() * M[2][2] + v.getZ() * M[2][2] + M[2][3]);
             
  return res;
} /* End of 'operator*' function */
开发者ID:aikide,项目名称:RayTracing,代码行数:16,代码来源:matr.cpp

示例3: Vec

/* Multiplication vector and matrix. (*this * v)
 * ARGUMENTS:
 * - vector to multiply from right
 *     Vec v;  
 * RETURNS:
 * - result vector
 *     Vec;
 */
Vec Matrix::operator*( Vec &v )
{
  Vec res = Vec(v.getX() * M[0][0] + v.getY() * M[1][0] + v.getZ() * M[2][0] + M[3][0],
  	            v.getX() * M[0][1] + v.getY() * M[1][1] + v.getZ() * M[2][1] + M[3][1],
	              v.getX() * M[0][2] + v.getY() * M[1][2] + v.getZ() * M[2][2] + M[3][2]);

  return res;
} /* End of 'operator*' function */
开发者ID:aikide,项目名称:RayTracing,代码行数:16,代码来源:matr.cpp

示例4: crossProd

Vec crossProd(const Vec &one, const Vec &two){
	GLdouble cp[3];

	cp[0] = one.getY() * two.getZ() - two.getY() * one.getZ();
	cp[1] = one.getZ() * two.getX() - two.getZ() * one.getX();
	cp[2] = one.getX() * two.getY() - two.getX() * one.getY();

	Vec result(cp[0], cp[1], cp[2]);

	return result;
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:11,代码来源:collision.cpp

示例5: searchInternal

void KdTree::searchInternal(KdNode* node,const BBox& bb,int d,List<VecItem*>& items){
	if( node ){
		Vec pn = node->item->getPosition();
		if( (d==0 && bb.getMinX()<pn.getX()) || bb.getMinY()<pn.getY() ){
			searchInternal(node->left,bb,(d+1)%m_k,items);
		}
		if( bb.contains(pn) ){
			items.append( node->item );
		}
		if( (d==0 && pn.getX()<=bb.getMaxX()) || pn.getY()<=bb.getMaxY() ){
			searchInternal(node->right,bb,(d+1)%m_k,items);
		}
	}
}
开发者ID:enriquefynn,项目名称:libvns,代码行数:14,代码来源:kdtree.cpp

示例6: if

//This function is stupid, I know.
//This is NOT a comparison of vector lengths!
//It needs to look this way for 'maps' to work...
bool Vec::operator<(const Vec vecA) const {
    
    Vec tmp = vecA;
    Vec tmp2 = *this;
    if (tmp2.getX() < tmp.getX()) {
        return true;
    }
    else if((tmp2.getX() == tmp.getX()) && (tmp2.getY() < tmp.getY())){
        return true;
    }
    else if((tmp2.getX() == tmp.getX()) && (tmp2.getY() == tmp.getY()) && (tmp2.getZ() < tmp.getZ())){
        return true;
    }
    else return false;
}
开发者ID:matja307,项目名称:TFYA50,代码行数:18,代码来源:vec.cpp

示例7:

Vec Vec::operator=(Vec vecA){

	x = vecA.getX();
	y = vecA.getY();
	z = vecA.getZ();
	return *this;
}
开发者ID:matja307,项目名称:TFYA50,代码行数:7,代码来源:vec.cpp

示例8: testIntPlane

//  Reference: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=30
GLint testIntPlane(const Plane &pl, const Vec &pos, const Vec &dir, GLdouble &lamda, const GLdouble offset){

    if ( (fabs(pl.position.getX() - pos.getX()) > offset) ||
         (fabs(pl.position.getZ() - pos.getZ()) > offset))
    {
        return 0;
    }
    
    /* Dot Product between the plane normal and ray direction */
	GLdouble theDotProd = dotProd(dir, pl.normal);
    
	GLdouble lam;
    
	// Determine If Ray Parallel To Plane
	if ((theDotProd < ZERO) && (theDotProd > -ZERO))
		return 0;
    
    /* Find the distance to the collision point */
    lam = dotProd(pl.position-pos, pl.normal);
    lam /= theDotProd;
    
	if (lam < -ZERO)							// Test If Collision Behind Start
		return 0;

	lamda=lam;
	return 1;
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:28,代码来源:collision.cpp

示例9:

Lighting::Lighting(Vec pos, Vec dir, char color, GLfloat spot, GLfloat intense, int lightNum, GLfloat colour[])
{
	this->white[0] = 1.0;
	this->white[1] = 1.0;
	this->white[2] = 1.0;
	this->white[3] = 1.0;

	this->red[0] = 1.0;
	this->red[1] = 0.0;
	this->red[2] = 0.0;
	this->red[3] = 1.0;

	this->green[0] = 0.0;
	this->green[1] = 1.0;
	this->green[2] = 0.0;
	this->green[3] = 1.0;

	this->blue[0] = 0.0;
	this->blue[1] = 0.0;
	this->blue[2] = 1.0;
	this->blue[3] = 1.0;

	this->other[0] = colour[0];
	this->other[1] = colour[1];
	this->other[2] = colour[2];
	this->other[3] = colour[3];

	this->position[0] = pos.getX();
	this->position[1] = pos.getY();
	this->position[2] = pos.getZ();
	this->position[3] = 1.0;
	
	this->direction[0] = dir.getX();
	this->direction[1] = dir.getY();
	this->direction[2] = dir.getZ();

	this->fSpotLight = spot;
	this->spotIntensity = intense;
	this->init(color, lightNum);
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:40,代码来源:lighting.cpp

示例10: CreateRotation

/* Create rotation Matrix.
 * ARGUMENTS:
 * - rotation angle in degrees
 *     float angle;
 * - rotation vector
 *     Vec radVec;
 * RETURNS: 
 * - rotation matrix
 *     Matrix ;
 */
Matrix CreateRotation( float angle, Vec &radVec )
{
  Matrix rot;
  /**/float si = sin(D2R(angle)), co = cos(D2R(angle)), len,
    radX = radVec.getX(), radY = radVec.getY(), radZ = radVec.getZ();  

  len = !radVec;
  if (len == 0)
    len = 1;
 
  radX /= len;
  radY /= len;
  radZ /= len;
		
  rot.SetElement(0, 0, co + radX * radX * (1 - co));
  rot.SetElement(0, 1, radX * radY * (1 - co) - radZ * si);
  rot.SetElement(0, 2, radX * radZ * (1 - co) + radY * si);

  rot.SetElement(1, 0, radX * radY * (1 - co) + radZ * si);
  rot.SetElement(1, 1, co + radY * radY * (1 - co));
  rot.SetElement(1, 2, radZ * radY * (1 - co) - radX * si);

  rot.SetElement(2, 0, radX * radZ * (1 - co) - radY * si);
  rot.SetElement(2, 1, radZ * radY * (1 - co) + radX * si);
  rot.SetElement(2, 2, co + radZ * radZ * (1 - co));/*


  float si = sin(D2R(angle / 2)), co = cos(D2R(angle / 2)), len,  // ÏÎËÎÂÈÍÍÛÉ ÓÃÎË!!!
    radX = radVec.getX(), radY = radVec.getY(), radZ = radVec.getZ();

  len = !radVec;
  if (len == 0)
    len = 1;
 
  radX *= si / len;
  radY *= si / len;
  radZ *= si / len;
		
  rot.SetElement(0, 0, 1 - 2 * (radY * radY + radZ * radZ));
  rot.SetElement(0, 1, 2 * radX * radY - 2 * co * radZ);
  rot.SetElement(0, 2, 2 * co * radY + 2 * radX * radZ);

  rot.SetElement(1, 0, 2 * radX * radY + 2 * co * radZ);
  rot.SetElement(1, 1, 1 - 2 * (radX * radX + radZ * radZ));
  rot.SetElement(1, 2, 2 * radY * radZ - 2 * co * radX);

  rot.SetElement(2, 0, 2 * radX * radZ - 2 * co * radY);
  rot.SetElement(2, 1, 2 * co * radX + 2 * radY * radZ);
  rot.SetElement(2, 2, 1 - 2 * (radX * radX + radY * radY));/**/

  return rot;
} /* End of 'CreateRotation' function */
开发者ID:aikide,项目名称:RayTracing,代码行数:62,代码来源:matr.cpp

示例11: randomDirection

void Trogdor::randomDirection(int randomInt, Vec &enemyPosition)
{
	if (this->facing == NORTH || this->facing == SOUTH)
	{
		if (randomInt % 10000 == 0)
		{
			if (this->position.getX() < enemyPosition.getX())
				this->facing = EAST;
			else if (this->position.getX() > enemyPosition.getX())
				this->facing = WEST;
		}
	}
	else //other direction
	{
		if (randomInt % 10000 == 0)
		{
			if (this->position.getZ() < enemyPosition.getZ())
				this->facing = SOUTH;
			else if (this->position.getZ() > enemyPosition.getZ())
				this->facing = NORTH;
		}
	}
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:23,代码来源:trogdor.cpp

示例12: testDist

GLdouble testDist(const Vec &p1, const Vec &p2){
	GLdouble x = p1.getX() - p2.getX();
	GLdouble z = p1.getZ() - p2.getZ();
	
	return sqrt(pow(x,2) + pow(z,2));	
}	
开发者ID:quandrei,项目名称:DragonCity,代码行数:6,代码来源:collision.cpp

示例13: ChooseDirection

void Trogdor::ChooseDirection(GLint nTile, GLint sTile, GLint eTile, GLint wTile, Vec &enemyPosition)
{
	if (this->facing == NORTH || this->facing == SOUTH)
	{
		if (wTile == 0 && this->position.getX() > enemyPosition.getX()) //westTile is not a wall and enemy is more west than trogdor
		{
			this->facing = WEST; //go west
		}
		else if (eTile == 0 && this->position.getX() < enemyPosition.getX()) //eastTile not a wall and enemy is more east than trogdor
		{
			this->facing = EAST; // go east
		}
		else if (nTile == 0 && this->position.getZ() > enemyPosition.getZ()) //northTile is not a wall and enemy is above trogdor
		{
			this->facing = NORTH; // go north
		}
		else if (sTile == 0 && this->position.getZ() < enemyPosition.getZ()) //southTile is not a wall and enemy is lower than trogdor
		{
			this->facing = SOUTH; //go south
		}
		else if (wTile == 0 && this->position.getX() > enemyPosition.getX()) //westTile is not a wall and enemy is more west than trogdor
		{
			this->facing = WEST; //go west
		}
		else if (eTile == 0) //no other conditions work try an available direction...
		{
			this->facing = EAST;
		}
		else if (nTile == 0)
		{
			this->facing = NORTH;
		}
		else if (sTile == 0)
		{
			this->facing = SOUTH;
		}
	}
	else //other two directions
	{
		if (nTile == 0 && this->position.getZ() > enemyPosition.getZ()) //northTile is not a wall and enemy is above trogdor
		{
			this->facing = NORTH; // go north
		}
		else if (sTile == 0 && this->position.getZ() < enemyPosition.getZ()) //southTile is not a wall and enemy is lower than trogdor
		{
			this->facing = SOUTH; //go south
		}
        else if (wTile == 0 && this->position.getX() > enemyPosition.getX()) //westTile is not a wall and enemy is more west than trogdor
		{
			this->facing = WEST; //go west
		}
        else if (eTile == 0 && this->position.getX() < enemyPosition.getX()) //eastTile not a wall and enemy is more east than trogdor
		{
			this->facing = EAST; // go east
		}
		else if (nTile == 0) //no other conditions work try an available direction...
		{
			this->facing = NORTH;
		}
		else if (sTile == 0)
		{
			this->facing = SOUTH;
		}
		else if (wTile == 0)
		{
			this->facing = WEST;
		}
		else if (eTile == 0)
		{
			this->facing = EAST;
		}
	}
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:73,代码来源:trogdor.cpp

示例14:

void Vec::operator= ( Vec other )
{
    this->x = other.getX();
    this->y = other.getY();
    this->z = other.getZ();
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:6,代码来源:vec.cpp

示例15: set

void Vec::set( const Vec &other )
{
    this->x = other.getX();
    this->y = other.getY();
    this->z = other.getZ();
}
开发者ID:quandrei,项目名称:DragonCity,代码行数:6,代码来源:vec.cpp


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