Skip to content

Instantly share code, notes, and snippets.

@bit-hack
Created January 15, 2018 00:08
Show Gist options
  • Select an option

  • Save bit-hack/19dd2844b6c48568a16c2a768eba52e8 to your computer and use it in GitHub Desktop.

Select an option

Save bit-hack/19dd2844b6c48568a16c2a768eba52e8 to your computer and use it in GitHub Desktop.
isometric transforms
// 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