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


C++ MathVector::dotProduct方法代码示例

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


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

示例1: tripleProduct

MathVector tripleProduct(MathVector a, MathVector b, MathVector c)
{
	MathVector U = b.multiply(c.dotProduct(a));
	MathVector V = a.multiply(c.dotProduct(b));

	return U.subtractVectors(V);
}
开发者ID:Grumblesaur,项目名称:sfml-game-engine,代码行数:7,代码来源:collision.cpp

示例2: buildMinkowskiDifference

minkowskiDifference_t buildMinkowskiDifference(std::vector<MathVector> a, std::vector<MathVector> b)
{
	MathVector direction = MathVector(1,1);
	std::vector<MathVector> simplex;
	simplex.push_back(getSupportVertex(a, b, direction));
	minkowskiDifference_t difference;

	direction = direction.negate();

	while(true)
	{
		simplex.push_back(getSupportVertex(a, b, direction));
		if(simplex.back().dotProduct(direction) <= 0)
		{
			difference.colliding = false;
			difference.collisionNormal = MathVector(0,0);
			difference.collisionDepth = 0;
			return difference;
		} else if(containsOrigin(simplex, direction) && simplex.size() == 3)
		{
			while(true)
			{
				//Perform EPA to get collision normal and penetration distance
				Edge_t e = findClosestEdge(simplex);

				MathVector p = getSupportVertex(a, b, direction);
				double d = p.dotProduct(e.normal);
//				std::cout << d - e.distance << std::endl;
//				std::cout << "Simplex size: " << simplex.size() << std::endl;
				if(d - e.distance < TOLERANCE)
				{
					difference.collisionNormal = e.normal;
					difference.collisionDepth = d;
					difference.colliding = true;
					return difference;
				} else
				{
//					std::cout << "Closest edge not found in this iteration, adding point to simplex and continuing." << std::endl;
					simplex.insert((simplex.begin()+e.index),p);
				}
			}
		}
	}
}
开发者ID:Grumblesaur,项目名称:sfml-game-engine,代码行数:44,代码来源:collision.cpp

示例3: getFurthestPoint

MathVector getFurthestPoint(MathVector direction, std::vector<MathVector> polygon)
	{
		double greatestDotProduct = -std::numeric_limits<double>::max();
		double currentDotProduct;
		MathVector currentVertex;
		MathVector bestVertex;
		for(int i = 0; i < polygon.size(); i++)
		{
			currentVertex = polygon[i];
			currentDotProduct = currentVertex.dotProduct(direction);
			if(currentDotProduct > greatestDotProduct)
			{
				greatestDotProduct = currentDotProduct;
				bestVertex = currentVertex;
			}
		}

		return bestVertex;

	}
开发者ID:Grumblesaur,项目名称:sfml-game-engine,代码行数:20,代码来源:collision.cpp

示例4:

typename MathVector<T>::value_type operator*(const MathVector<T>& lhs, const MathVector<T>& rhs)
{
  return lhs.dotProduct(rhs);
}
开发者ID:DaWeish,项目名称:cs5201-final-project-temp,代码行数:4,代码来源:MathVector.hpp


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