本文整理汇总了C++中Vec::getZ方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec::getZ方法的具体用法?C++ Vec::getZ怎么用?C++ Vec::getZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec
的用法示例。
在下文中一共展示了Vec::getZ方法的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);
}
示例2: 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 */
示例3: 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 */
示例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;
}
示例5:
Vec Vec::operator=(Vec vecA){
x = vecA.getX();
y = vecA.getY();
z = vecA.getZ();
return *this;
}
示例6: 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;
}
示例7:
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);
}
示例8: 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 */
示例9: 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;
}
}
}
示例10: 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));
}
示例11: set
void Vec::set( const Vec &other )
{
this->x = other.getX();
this->y = other.getY();
this->z = other.getZ();
}
示例12:
void Vec::operator= ( Vec other )
{
this->x = other.getX();
this->y = other.getY();
this->z = other.getZ();
}
示例13: result
Vec Vec::operator- ( const Vec &other ) const
{
Vec result(this->x - other.getX(), this->y - other.getY(), this->z - other.getZ());
return result;
}
示例14: 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;
}
}
}
示例15: newVec
Vec Vec::operator+(Vec vecA){
Vec newVec(vecA.getX()+this->getX(),vecA.getY()+this->getY(),vecA.getZ()+this->getZ());
return newVec;
}