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


C++ Magnitude函数代码示例

本文整理汇总了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;
}
开发者ID:lukemonaghan,项目名称:YR01_03_Refactor_MathLibrary,代码行数:8,代码来源:Vector4.cpp

示例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);
		}
	}
}
开发者ID:UIKit0,项目名称:Chicken-Tournament,代码行数:25,代码来源:ComputerBauer.cpp

示例3: Magnitude

	void Vector3::Normalise()
	{
		float fMag = Magnitude();
		m_fX /= fMag;
		m_fY /= fMag;
		m_fZ /= fMag;
	}
开发者ID:terrehbyte,项目名称:terrehbyte-math-library,代码行数:7,代码来源:vec3.cpp

示例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();
		}
	}
}
开发者ID:UIKit0,项目名称:Chicken-Tournament,代码行数:26,代码来源:ComputerBauer.cpp

示例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;
}
开发者ID:UIKit0,项目名称:Chicken-Tournament,代码行数:30,代码来源:ComputerBauer.cpp

示例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);
}
开发者ID:Kallontz,项目名称:gunz-the-tps-mmorpg,代码行数:26,代码来源:ZCharacterObject.cpp

示例7: Magnitude

/* Normalize */
void Vector4::Normalize(void) {
	float mag = Magnitude();

	x /= mag;
	y /= mag;
	z /= mag;
}
开发者ID:CaptKH,项目名称:IceBreaker,代码行数:8,代码来源:Vector4.cpp

示例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;
}
开发者ID:ennui-games,项目名称:praxis,代码行数:25,代码来源:ML_Vector.cpp

示例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);
}
开发者ID:nanzhang790,项目名称:View3dn,代码行数:26,代码来源:thinshell3_element-BAK3.cpp

示例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();
	}
}
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:31,代码来源:ZClothEmblem.cpp

示例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;

}
开发者ID:Redrock912,项目名称:reboot,代码行数:30,代码来源:transform.cpp

示例12: Distance

const float Distance(	const TVector2f& _krA,
							const TVector2f& _krB)
{
	const float kfDistance = Magnitude(Subtract(TVector2f(), _krA, _krB));

	return(kfDistance);
}
开发者ID:chronokun,项目名称:CkMath,代码行数:7,代码来源:ckmath_vector.cpp

示例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) };
}
开发者ID:quepas,项目名称:Aberrant-Furious-Frostbite,代码行数:7,代码来源:math_vector3.hpp

示例14: Magnitude

//Normilization
void Vector2Math::Normalize()
{
	float Length = Magnitude();
	x /= Length;
	y /= Length;

}
开发者ID:MattBeaud,项目名称:MathLibrary,代码行数:8,代码来源:Vector2.cpp

示例15: Magnitude

void Vector3::Normalized()
{
	float length = Magnitude();
	this->x /= length;
	this->y /= length;
	this->z /= length;
}
开发者ID:SebastianMechler,项目名称:Engine,代码行数:7,代码来源:Vector3.cpp


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