if (!Vec3DUtils.isNormalized(v)) {
LOGGER.log(Level.FINEST, v + " is not normalized. Might end up with incorrect rotation");
}
Vec3D translation = new Vec3D();
// X
if (Math.abs(up.x) == 1) {
// Change the centroid
translation.set(centroid.x, centroid.y, centroid.z);
// X = 1
if (up.x == 1) {
transpose(v, translation, Vec3D.Z_AXIS, (float) -Math.PI/2);
}
// X = -1
else {
transpose(v, translation, Vec3D.Z_AXIS, (float) Math.PI/2);
}
}
// Y
else if (Math.abs(up.y) == 1) {
translation.set(centroid.x, centroid.y, centroid.z);
// Y = 1
if (up.y == 1) {
transpose(v, translation, Vec3D.Z_AXIS, (float) Math.PI);
}
// Y = -1
// Do nothing
}
// Z
else {
// Z = 1
if (up.z == 1) {
v.addSelf(new Vec3D(0, 0, -centroid.z*2));
translation.set(0, 0, 0f);
transpose(v, translation, Vec3D.X_AXIS, (float) Math.PI/2);
}
//Z = -1
else {
translation.set(centroid.x, 0, centroid.z);
transpose(v, translation, Vec3D.Y_AXIS, (float) Math.PI);
translation.set(0, 0, 0);
transpose(v, translation, Vec3D.X_AXIS, (float) Math.PI/2);
v.addSelf(0, 1f, 0);
}
}
}