Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MrTelanie/3bcbcf22692b6068e7b5a54c6983176b to your computer and use it in GitHub Desktop.

Select an option

Save MrTelanie/3bcbcf22692b6068e7b5a54c6983176b to your computer and use it in GitHub Desktop.
method vs. Operator
/**
* https://github.com/jMonkeyEngine/jmonkeyengine/blob/d57c362ec3b510c1ba6356f719efa3b1576b95c6/jme3-core/src/main/java/com/jme3/math/Transform.java#L237
*/
transformVector(in, store){
// multiply with scale first, then rotate, finally translate (cf.
// Eberly)
return rot.mult(store.set(in).multLocal(scale), store).addLocal(translation);
}
transformInverseVector(in, store){
// The author of this code should look above and take the inverse of that
// But for some reason, they didn't ..
// in.subtract(translation, store).divideLocal(scale);
// rot.inverse().mult(store, store);
in.subtract(translation, store);
rot.inverse().mult(store, store);
store.divideLocal(scale);
return store;
}
transformVector(in) {
return (rot * (in * scale)) + translation;
}
transformInverseVector(in){
return ((in - translation) * rot.inverse()) / scale);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment