Created
January 15, 2018 00:08
-
-
Save bit-hack/19dd2844b6c48568a16c2a768eba52e8 to your computer and use it in GitHub Desktop.
isometric transforms
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
| // convert world to screen | |
| vec2f_t to_screen(const vec3f_t &p) const { | |
| return vec2f_t{ | |
| 2.f * (p.x - p.y), | |
| p.x + p.y - p.z, | |
| }; | |
| } | |
| // convert screen to world | |
| vec3f_t to_world(const vec2f_t &p, float worldz) const { | |
| return vec2f_t{ | |
| .5 * (worldz + p.y) + .25 * p.x, | |
| .5 * (worldz + p.y) - .25 * p.x, | |
| wz | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment