Created
May 7, 2019 17:20
-
-
Save MrTelanie/3bcbcf22692b6068e7b5a54c6983176b to your computer and use it in GitHub Desktop.
method vs. Operator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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