本文整理汇总了C++中Magnitude函数的典型用法代码示例。如果您正苦于以下问题:C++ Magnitude函数的具体用法?C++ Magnitude怎么用?C++ Magnitude使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Magnitude函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Magnitude
//Normalize of 4D vector (on self)
void Vector4::Normalize(){
float len = Magnitude();
w/=len;
x/=len;
y/=len;
z/=len;
}
示例2: HandleGolfer
void CComputerBauer::HandleGolfer(const float elapsed)
{
CChicken* c=(CChicken*)SearchNextChicken();
if (c==NULL)return;
// um 0.07 RAD weiter nach links drehen um noch richtig zu zielen
float w=GetWinkel(ang.y,c->pos)-0.07f;
float entf=Magnitude(pos-c->pos);
if (abs(w)>0.025f)w=RotateTo(w,elapsed*((entf<13.0f)?2.25f:1.0f));
if (entf>1.5f)speed.z=4.4f;
else speed.z=0.0f;
if ((w<0.1f)&&(entf<2.0f))
{ // Zuschlagen
ang.x=-0.2f;
CGolfer* g=(CGolfer*)object;
if (g->Schlag())
{
g->SendNotify(3);
}
}
}
示例3: Magnitude
void Vector3::Normalise()
{
float fMag = Magnitude();
m_fX /= fMag;
m_fY /= fMag;
m_fZ /= fMag;
}
示例4: HandleGartenkralle
void CComputerBauer::HandleGartenkralle(const float elapsed)
{
CChicken* c=(CChicken*)SearchNextChicken();
if (c==NULL)return;
// um 0.07 RAD weiter nach links drehen um noch richtig zu zielen
float w=GetWinkel(ang.y,c->pos)-0.07f;
float entf=Magnitude(pos-c->pos);
if (abs(w)>0.02f)w=RotateTo(w,elapsed*((entf<13.0f)?2.25f:1.0f));
if (entf>1.3f)speed.z=4.0f;
else speed.z=0.0f;
if ((w<0.1f)&&(entf<1.8f))
{ // Zustechen
ang.x=-0.45f;
CGartenkralle* g=(CGartenkralle*)object;
if (g->Stoss())
{
g->SendNotify(2);
g->EndStoss();
}
}
}
示例5: HandleDrescher
void CComputerBauer::HandleDrescher(const float elapsed)
{
CChicken* c=SearchNextChicken();
CDrescher* d=(CDrescher*)object;
if (c==NULL)
{ // Ist kein Huhn in der Nähe, einfach stumpfsinnig in einem kleinen Kreis weiterfahren
d->rot=0.35f;
return;
}
d->acc.z=5.5f;
float w=GetWinkel(d->ang.y,c->pos);
if (abs(w)<0.1f)
{ // Wenn Winkeldiffenenz zu klein, Kurs einfach beibehalten ohne zu lenken
d->rot=0.0f;
return;
}
// Drehen
if ((abs(w)>g_PI/2.0f)&&(Magnitude(pos-c->pos)<12.0f)&&(world->GetDistanceFromWall(pos)>5.0f))
{ // Wenn Ziel hinter Mähdrescher ist, weiterfahren bis es mit der Kurve erwischt werden kann
d->rot=0.0f;
return;
}
// Sonst Mähdrescher in Richtung des Huhns drehen
if (w<0.0f)d->rot=-1.0f;
else d->rot=+1.0f;
}
示例6: AddVelocity
void ZCharacterObject::OnKnockback(rvector& dir, float fForce)
{
AddVelocity(dir * fForce);
// ³Ë¹é ÃÖ´ë¼Óµµ¿¡ ¸ÂÃá´Ù
rvector vel = GetVelocity();
if (Magnitude(vel) > MAX_KNOCKBACK_VELOCITY) {
Normalize(vel);
vel *= MAX_KNOCKBACK_VELOCITY;
SetVelocity(vel);
}
// Ÿ°Ý°¨ - ²ÞƲ
rvector dir1 = m_Direction;
rvector dir2 = dir;
Normalize(dir2);
float cosAng1 = DotProduct(dir1, dir2);
float fMaxValue = m_fTremblePower;
if (cosAng1 < 0.f) {
fMaxValue = -fMaxValue;
}
Tremble(fMaxValue, 50, 100);
}
示例7: Magnitude
/* Normalize */
void Vector4::Normalize(void) {
float mag = Magnitude();
x /= mag;
y /= mag;
z /= mag;
}
示例8: Magnitude
void mlVector3D::Normalise()
{
mlFloat maxValue = 0.0f;
if(mlFabs(x) > maxValue) maxValue = mlFabs(x);
if(mlFabs(y) > maxValue) maxValue = mlFabs(y);
if(mlFabs(z) > maxValue) maxValue = mlFabs(z);
if(maxValue == 0.0f)
return;
x = x / maxValue;
y = y / maxValue;
z = z / maxValue;
mlFloat mag = Magnitude();
if(mag == 0.0f)
return;
mlFloat invMag = 1.0f / mag;
x *= invMag;
y *= invMag;
z *= invMag;
}
示例9: getReferencePlanesForQuadPair
//use the center plane of the dihedral angle as the reference plane
inline void getReferencePlanesForQuadPair(
const Vector3d &p1, const Vector3d &p2, const Vector3d &p3, const Vector3d &p4, const Vector3d &p5,
Vector3d &facenorm0, Vector3d &facenorm1, double3x3& mat, double &xlen)
{
Vector3d Y0, Y1;
Vector3d &Z0 = facenorm0;
Vector3d &Z1 = facenorm1;
Vector3d &X = *((Vector3d*)(&mat.x[0]));
Vector3d &Y = *((Vector3d*)(&mat.x[3]));
Vector3d &Z = *((Vector3d*)(&mat.x[6]));
const Vector3d p23 = (p2+p3)*0.5; //quad center
const Vector3d p45 = (p4+p5)*0.5; //quad center
X = p1;
xlen = Magnitude(X);
X /= xlen; //normalize
Y0 = p23;
Z0 = CrossProd(X, Y0);
Y1 = p45;
Z1 = CrossProd(Y1, X);
Z0.Normalize();
Z1.Normalize();
Z = Z0+Z1;
Z.Normalize();
Y = CrossProd(Z, X);
}
示例10: Magnitude
//////////////////////////////////////////////////////////////////////////
// ZEmblemList
//////////////////////////////////////////////////////////////////////////
void ZEmblemList::Draw()
{
rvector camera_pos = RealSpace2::RCameraPosition;
rvector t_vec;
rvector t_pos;
for( iterator iter = begin(); iter != end(); ++iter )
{
ZClothEmblem* pCurr = *iter;
if( pCurr == NULL) continue;
t_pos.x = pCurr->mWorldMat._41;
t_pos.y = pCurr->mWorldMat._42;
t_pos.z = pCurr->mWorldMat._43;
t_vec = camera_pos - t_pos;
pCurr->m_fDist = Magnitude(t_vec);
}
sort(e_clothemblem_sort_float);
for( iterator iter = begin(); iter != end(); ++iter )
{
ZClothEmblem* pCurr = *iter;
if(pCurr != 0) pCurr->render();
}
}
示例11: Rotate
// rotate about u-axis
Matrix4D Rotate(const Matrix4D &m,const Vector3D& u, float theta)
{
float x, y, z,w;
x = u.x;
y = u.y;
z = u.z;
w=Magnitude(u);
float ux, uy, uz,ud,xtheta,ytheta;
ux = x / w;
uy = y / w;
uz = z / w;
ud = pow(pow(uy, 2) + pow(uz, 2), 0.5);
xtheta = acos(uy / ud);
ytheta = acos(ud);
Matrix4D temp;
temp = Translate(x, y, z)*m;
temp = RotateX(ytheta)*temp;
temp = RotateY(ytheta)*temp;
temp = RotateZ(theta)*temp;
temp = Inverse(RotateY(ytheta))*temp;
temp = Inverse(RotateX(xtheta))*temp;
temp = Inverse(Translate(x, y, z))*temp;
return temp;
}
示例12: Distance
const float Distance( const TVector2f& _krA,
const TVector2f& _krB)
{
const float kfDistance = Magnitude(Subtract(TVector2f(), _krA, _krB));
return(kfDistance);
}
示例13: Magnitude
Vector3<T> Vector3<T>::Normalize() const
{
float magnitude = Magnitude();
return { static_cast<T>(x / magnitude),
static_cast<T>(y / magnitude),
static_cast<T>(z / magnitude) };
}
示例14: Magnitude
//Normilization
void Vector2Math::Normalize()
{
float Length = Magnitude();
x /= Length;
y /= Length;
}
示例15: Magnitude
void Vector3::Normalized()
{
float length = Magnitude();
this->x /= length;
this->y /= length;
this->z /= length;
}