Ejemplo n.º 1
0
		//btVector3 PlaneLineIntersection( btPlane &plane, btVector3 p0, btVector3 p1);
		//btVector3 PlaneProject( btPlane &plane, btVector3 point);

		void ThreePlaneIntersection( ref btPlane p0
			, ref btPlane p1
			, ref btPlane p2
			, out btVector3 result )
		{

			btVector3 n2n3; p1.normal.cross( ref p2.normal, out n2n3 );
			btVector3 n3n1; p2.normal.cross( ref p0.normal, out n3n1 );
			btVector3 n1n2; p0.normal.cross( ref p1.normal, out n1n2 );

			double quotient = ( p0.normal.dot( ref n2n3 ) );

			Debug.Assert( btScalar.btFabs( quotient ) > 0.000001 );

			quotient = -1.0 / quotient;
			n2n3.Mult( p0.dist, out n2n3 );
			n3n1.Mult( p1.dist, out n3n1 );
			n1n2.Mult( p2.dist, out n1n2 );
			btVector3 potentialVertex;
			n2n3.Add( ref n3n1, out potentialVertex );
			potentialVertex.Add( ref n3n1, out potentialVertex );
			potentialVertex.Add( ref n1n2, out potentialVertex );
			potentialVertex.Mult( quotient, out result );
		}
Ejemplo n.º 2
0
		PlaneTest SplitTest( ConvexH convex, btPlane plane )
		{
			PlaneTest flag = 0;
			int c = convex.vertices.Count;
			btVector3[] array = convex.vertices.InternalArray;
			for( int i = 0; i < c; i++ )
			{
				flag |= DoPlaneTest( ref plane, ref array[i] );
			}
			return flag;
		}
Ejemplo n.º 3
0
		PlaneTest DoPlaneTest( ref btPlane p, ref btVector3 v )
		{
			double a = v.dot( ref p.normal ) + p.dist;
			PlaneTest flag = ( a > planetestepsilon )
				? PlaneTest.OVER
				: ( ( a < -planetestepsilon )
						? PlaneTest.UNDER
						: PlaneTest.COPLANAR );
			return flag;
		}