Skip to content

Instantly share code, notes, and snippets.

Created August 31, 2012 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3558420 to your computer and use it in GitHub Desktop.
Save anonymous/3558420 to your computer and use it in GitHub Desktop.
Test3
// a00
originDistance0 = triangle.p0.y * ( triangle.p1.z - triangle.p0.z )
- triangle.p0.z * ( triangle.p1.y - triangle.p0.y );
originDistance2 = ( triangle.p2.z * ( triangle.p1.y - triangle.p0.y ) )
- ( triangle.p2.y * ( triangle.p1.z - triangle.p0.z ) );
projectionRadius = extent1 * Math.abs( edge0.z ) + extent2 * Math.abs( edge0.y );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a01
originDistance0 = triangle.p0.y * ( triangle.p2.z - triangle.p1.z )
- triangle.p0.z * ( triangle.p2.y - triangle.p1.y );
originDistance2 = ( triangle.p2.z * ( triangle.p2.y - triangle.p1.y ) )
- ( triangle.p2.y * ( triangle.p2.z - triangle.p1.z ) );
projectionRadius = extent1 * Math.abs( edge1.z ) + extent2 * Math.abs( edge1.y );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a02
originDistance0 = triangle.p0.y * ( triangle.p0.z - triangle.p2.z )
- triangle.p0.z * ( triangle.p0.y - triangle.p2.y );
originDistance2 = ( triangle.p2.z * ( triangle.p0.y - triangle.p2.y ) )
- ( triangle.p2.y * ( triangle.p0.z - triangle.p2.z ) );
projectionRadius = extent1 * Math.abs( edge2.z ) + extent2 * Math.abs( edge2.y );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a10
originDistance0 = triangle.p0.x * ( triangle.p1.z - triangle.p0.z )
- triangle.p0.z * ( triangle.p1.x - triangle.p0.x );
originDistance2 = ( triangle.p2.z * ( triangle.p1.x - triangle.p0.x ) )
- ( triangle.p2.x * ( triangle.p1.z - triangle.p0.z ) );
projectionRadius = extent1 * Math.abs( edge0.z ) + extent2 * Math.abs( edge0.x );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a11
originDistance0 = triangle.p0.x * ( triangle.p2.z - triangle.p1.z )
- triangle.p0.z * ( triangle.p2.x - triangle.p1.x );
originDistance2 = ( triangle.p2.z * ( triangle.p2.x - triangle.p1.x ) )
- ( triangle.p2.x * ( triangle.p2.z - triangle.p1.z ) );
projectionRadius = extent1 * Math.abs( edge1.z ) + extent2 * Math.abs( edge1.x );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a12
originDistance0 = triangle.p0.x * ( triangle.p0.z - triangle.p2.z )
- triangle.p0.z * ( triangle.p0.x - triangle.p2.x );
originDistance2 = ( triangle.p2.z * ( triangle.p0.x - triangle.p2.x ) )
- ( triangle.p2.x * ( triangle.p0.z - triangle.p2.z ) );
projectionRadius = extent1 * Math.abs( edge2.z ) + extent2 * Math.abs( edge2.x );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a20
originDistance0 = triangle.p0.y * ( triangle.p1.x - triangle.p0.x )
- triangle.p0.x * ( triangle.p1.y - triangle.p0.y );
originDistance2 = ( triangle.p2.y * ( triangle.p1.x - triangle.p0.x ) )
- ( triangle.p2.x * ( triangle.p1.y - triangle.p0.y ) );
projectionRadius = extent1 * Math.abs( edge0.y ) + extent2 * Math.abs( edge0.x );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a21
originDistance0 = triangle.p0.y * ( triangle.p2.x - triangle.p1.x )
- triangle.p0.x * ( triangle.p2.y - triangle.p1.y );
originDistance2 = ( triangle.p2.y * ( triangle.p2.x - triangle.p1.x ) )
- ( triangle.p2.x * ( triangle.p2.y - triangle.p1.y ) );
projectionRadius = extent1 * Math.abs( edge1.y ) + extent2 * Math.abs( edge1.x );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
// a22
originDistance0 = triangle.p0.y * ( triangle.p0.x - triangle.p2.x )
- triangle.p0.x * ( triangle.p0.y - triangle.p2.y );
originDistance2 = ( triangle.p2.y * ( triangle.p0.x - triangle.p2.x ) )
- ( triangle.p2.x * ( triangle.p0.y - triangle.p2.y ) );
projectionRadius = extent1 * Math.abs( edge2.y ) + extent2 * Math.abs( edge2.x );
if ( Math.max( -Math.max( originDistance0, originDistance2 ), Math.min( originDistance0, originDistance2 ) ) > projectionRadius ) {
return false; // Axis is a separating axis
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment