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


C++ Point::Magnitude方法代码示例

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


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

示例1: BatchCapsuleSweeps

udword PhysX::BatchCapsuleSweeps(PintSQThreadContext context, udword nb, PintRaycastHit* dest, const PintCapsuleSweepData* sweeps)
{
	ASSERT(mScene);

	const PxQueryFilterData PF = GetSQFilterData();
	const PxSceneQueryFlags sweepQueryFlags = GetSweepQueryFlags(mParams);

	udword NbHits = 0;
	while(nb--)
	{
		const Point Center = (sweeps->mCapsule.mP0 + sweeps->mCapsule.mP1)*0.5f;
		Point CapsuleAxis = sweeps->mCapsule.mP1 - sweeps->mCapsule.mP0;
		const float M = CapsuleAxis.Magnitude();
		CapsuleAxis /= M;
		const PxQuat q = PxShortestRotation(PxVec3(1.0f, 0.0f, 0.0f), ToPxVec3(CapsuleAxis));

		const PxTransform Pose(ToPxVec3(Center), q);

		PxSweepHit Hit;
		if(mScene->sweepSingle(PxCapsuleGeometry(sweeps->mCapsule.mRadius, M*0.5f), Pose, ToPxVec3(sweeps->mDir), sweeps->mMaxDist, sweepQueryFlags, Hit, PF))
		{
			NbHits++;
			FillResultStruct(*dest, Hit);
		}
		else
		{
			dest->mObject = null;
		}

		sweeps++;
		dest++;
	}
	return NbHits;
}
开发者ID:Pierre-Terdiman,项目名称:PEEL,代码行数:34,代码来源:PINT_PhysX32.cpp

示例2: Point

Matrix& Matrix::ComputeAxisMatrix(Point& axis, float angle)
{
	MakeIdentity();

	float length = axis.Magnitude();
	// Normalize the z basis vector3
	axis /= length;

	// Get the dot product, and calculate the projection of the z basis
	// vector3 onto the up vector3. The projection is the y basis vector3.
	float dotProduct = Point(0, 1, 0) | axis;
	Point Up = Point(0, 1, 0) - dotProduct * axis;

	// This is to prevent bogus view matrix (up view vector3 equals to axis)
	if (Up.Magnitude() < 1e-6f)	{
		Up = Point(0, 0, 1);
	}
	else	{
	// Normalize the y basis vector3
		Up /= length;
		Up.Normalize();
	}

	// The x basis vector3 is found simply with the cross product of the y
	// and z basis vectors
	Point Right = Up ^ axis;

	SetCol( 0, Right );
	SetCol( 1, Up );
	SetCol( 2, axis );
	Transpose();

	return *this;
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:34,代码来源:OPC_Matrix4x4.cpp

示例3: Angle

	//**************************************
	// Angle between two vectors (in radians)
	// we use this formula
	// uv = |u||v| cos(u,v)
	// u  ^ v  = w
	// |w| = |u||v| |sin(u,v)|
	//**************************************
	float Angle(const Point& u, const Point& v)
	{
		float NormU = u.Magnitude();	// |u|
		float NormV = v.Magnitude();	// |v|
		float Product = NormU*NormV;	// |u||v|
		if(Product==0.0f)	return 0.0f;
		float OneOverProduct = 1.0f / Product;

		// Cosinus
		float Cosinus = (u|v) * OneOverProduct;

		// Sinus
		Point w = u^v;
		float NormW = w.Magnitude();

		float AbsSinus = NormW * OneOverProduct;

		// Remove degeneracy
		if(AbsSinus > 1.0f) AbsSinus = 1.0f;
		if(AbsSinus < -1.0f) AbsSinus = -1.0f;

		if(Cosinus>=0.0f)	return asinf(AbsSinus);
		else				return (PI-asinf(AbsSinus));
	}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:31,代码来源:IceIndexedTriangle.cpp

示例4: NormalizePRSMatrix

void IceMaths::NormalizePRSMatrix(Matrix4x4& dest, Point& scale, const Matrix4x4& src)
{
	Point row;
	dest = src;
	for( int i=0;i<3;i++)
	{
		src.GetRow(i,row);

		// computes scales

		scale[i] = row.Magnitude();

		row /= scale[i];

		dest.SetRow(i,row);
	}
}
开发者ID:Arsakes,项目名称:ember,代码行数:17,代码来源:IceMatrix4x4.cpp

示例5:

// Vector normalization can handle a Near-Zero Magnitude
TEST_F(PointTest, NormNearZeroMag) {
  Point p = NearZeroMag_; 
  p = p.Normalize();
  EXPECT_FALSE(p.Equals(ZeroMag_)) << "Normalize near 0 vector == 0 vector";
  ASSERT_EQ(p.Magnitude(), 1)  << "Normalize near 0 vector: Mag != 1";
}
开发者ID:hayesbh,项目名称:Phasespace_Object_Server,代码行数:7,代码来源:PointTest.cpp


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