Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Created September 10, 2012 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save knownasilya/3691088 to your computer and use it in GitHub Desktop.
project on axes
public static Projection project( Vector3d[] vertices, Vector3d axis ) {
double min = axis.dot( vertices[ 0 ] );
double max = min;
for (int i = 1; i < vertices.length; i++) {
// NOTE: the axis must be normalized to get accurate projections
double p = axis.dot( vertices[ i ] );
if ( p < min ) {
min = p;
} else if ( p > max ) {
max = p;
}
}
Projection proj = new Projection( min, max );
return proj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment