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


C++ float2::dot方法代码示例

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


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

示例1: PolyShapeValueOnAxis

static inline float PolyShapeValueOnAxis(SimBody *poly, const float2 n, const float d)
{
	vector<float2> &verts = poly->transformedVertices;
	float minft = n.dot(verts[0]);

	for(u32 i=1;i<verts.size();++i)
	{
		minft = min(minft, n.dot(verts[i]));
	}

	return minft - d;
};
开发者ID:wrdn,项目名称:2DPhysics,代码行数:12,代码来源:chipCollide.cpp

示例2: SATCollide

bool SATCollide(SimBody *body1, SimBody *body2, float2 &N, f32 &t)
{
	SimBody &a = *body1;
	SimBody &b = *body2;

	if(a.vertices.size() < 2 && b.vertices.size() < 2) return false;

	Mat22 OA = Mat22::RotationMatrix(a.rotation_in_rads);
	Mat22 OB = Mat22::RotationMatrix(b.rotation_in_rads);
	Mat22 OB_T = OB.Transpose();

	Mat22 xOrient = OA * OB_T;
	float2 xOffset = (a.position - b.position) * OB_T;

	const u32 MAX_SEPERATING_AXIS = 16; 
	float2 xAxis[MAX_SEPERATING_AXIS];
	f32 taxis[MAX_SEPERATING_AXIS];
	u32 axisCount = 0;

	for(u32 i=0;i<a.seperatingAxis.size();++i)
	{
		xAxis[axisCount] = a.seperatingAxis[i] * xOrient;
		if(!IntervalIntersect(a.vertices, b.vertices, xAxis[axisCount],
			xOffset, xOrient, taxis[axisCount], t))
		{
			return false;
		}
		++axisCount;
	};
	for(u32 i=0;i<b.seperatingAxis.size();++i)
	{
		xAxis[axisCount] = b.seperatingAxis[i];
		if(!IntervalIntersect(a.vertices, b.vertices, xAxis[axisCount],
			xOffset, xOrient, taxis[axisCount], t))
		{
			return false;
		}
		++axisCount;
	};

	if(!GetMinimumTranslationVector(xAxis, taxis, axisCount, N, t))
	{
		return false;
	}

	f32 D = N.dot(xOffset);
	N =  D < 0.0f ? -N : N;

	N = N * OB;

	return true;
};
开发者ID:wrdn,项目名称:2DPhysics,代码行数:52,代码来源:SATCollide.cpp

示例3: IntervalIntersect

bool IntervalIntersect(const std::vector<float2> &aVertices,
		const std::vector<float2> &bVertices, const float2 &axis, const float2 &relPos,
		const Mat22 &xOrient, f32 &taxis, f32 tmax)
{
	SATProjection proj0 = GetInterval(aVertices, axis * xOrient.Transpose());
	SATProjection proj1 = GetInterval(bVertices, axis);
	
	f32 h = relPos.dot(axis);
	proj0.min += h;
	proj0.max += h;

	f32 d0 = proj0.min - proj1.max;
	f32 d1 = proj1.min - proj0.max;

	if(d0 > 0.0f || d1 > 0.0f)
	{
		return false;
	}

	taxis = d0 > d1 ? d0 : d1;
	return true;
};
开发者ID:wrdn,项目名称:2DPhysics,代码行数:22,代码来源:SATCollide.cpp

示例4:

inline const float operator *(const float2& a, const float2& b)
{
  return a.dot(b);
}
开发者ID:Caleydo,项目名称:visuallinks,代码行数:4,代码来源:float2.hpp


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