diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-06-14 19:25:13 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-06-14 19:25:13 -0400 |
commit | 4a28a6ac23f92f5d1ce13e369b27be22815aec6c (patch) | |
tree | 4ff535a2050c3af4eff41ab63a1f7de681edfe4d | |
parent | 6e2d60d822c52562b29e814adeeeac33f8f24ebd (diff) | |
download | dimension-4a28a6ac23f92f5d1ce13e369b27be22815aec6c.tar.xz |
geometry: Clean up dmnsn_transform_bounding_box() a bit.
-rw-r--r-- | libdimension/geometry.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/libdimension/geometry.c b/libdimension/geometry.c index c93dd11..5ce7d64 100644 --- a/libdimension/geometry.c +++ b/libdimension/geometry.c @@ -369,29 +369,20 @@ dmnsn_transform_bounding_box(dmnsn_matrix trans, dmnsn_bounding_box box) } } - dmnsn_vector Mx = dmnsn_matrix_column(trans, 0); - dmnsn_vector xmin = dmnsn_vector_mul(box.min.x, Mx); - dmnsn_vector xmax = dmnsn_vector_mul(box.max.x, Mx); - - dmnsn_vector My = dmnsn_matrix_column(trans, 1); - dmnsn_vector ymin = dmnsn_vector_mul(box.min.y, My); - dmnsn_vector ymax = dmnsn_vector_mul(box.max.y, My); - - dmnsn_vector Mz = dmnsn_matrix_column(trans, 2); - dmnsn_vector zmin = dmnsn_vector_mul(box.min.z, Mz); - dmnsn_vector zmax = dmnsn_vector_mul(box.max.z, Mz); - dmnsn_vector Mt = dmnsn_matrix_column(trans, 3); + dmnsn_bounding_box ret = { Mt, Mt }; - dmnsn_bounding_box ret; + dmnsn_vector Mz = dmnsn_matrix_column(trans, 2); + ret.min = dmnsn_vector_add(ret.min, dmnsn_vector_mul(box.min.z, Mz)); + ret.max = dmnsn_vector_add(ret.max, dmnsn_vector_mul(box.max.z, Mz)); - ret.min = dmnsn_vector_add(xmin, ymin); - ret.min = dmnsn_vector_add(ret.min, zmin); - ret.min = dmnsn_vector_add(ret.min, Mt); + dmnsn_vector My = dmnsn_matrix_column(trans, 1); + ret.min = dmnsn_vector_add(ret.min, dmnsn_vector_mul(box.min.y, My)); + ret.max = dmnsn_vector_add(ret.max, dmnsn_vector_mul(box.max.y, My)); - ret.max = dmnsn_vector_add(xmax, ymax); - ret.max = dmnsn_vector_add(ret.max, zmax); - ret.max = dmnsn_vector_add(ret.max, Mt); + dmnsn_vector Mx = dmnsn_matrix_column(trans, 0); + ret.min = dmnsn_vector_add(ret.min, dmnsn_vector_mul(box.min.x, Mx)); + ret.max = dmnsn_vector_add(ret.max, dmnsn_vector_mul(box.max.x, Mx)); return ret; } |