summaryrefslogtreecommitdiffstats
path: root/dimension/realize.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-10-30 11:58:37 -0400
committerTavian Barnes <tavianator@gmail.com>2009-10-30 11:58:37 -0400
commit05757a852b46c40354f18d4f0c547d6b339054ab (patch)
tree07ab3f9def198d7979c8deb49472437aaa804cd8 /dimension/realize.c
parent58e698772d6b48817fdff3a2d36f445c70e87ee3 (diff)
downloaddimension-05757a852b46c40354f18d4f0c547d6b339054ab.tar.xz
Don't flip boxes that are specified backwards.
Diffstat (limited to 'dimension/realize.c')
-rw-r--r--dimension/realize.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/dimension/realize.c b/dimension/realize.c
index 286bae7..38a74e6 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -20,6 +20,7 @@
#include "realize.h"
#include "parse.h"
#include "utility.h"
+#include <math.h>
static dmnsn_vector
dmnsn_realize_vector(dmnsn_astnode astnode)
@@ -59,9 +60,11 @@ dmnsn_realize_box(dmnsn_astnode astnode)
x2 = dmnsn_realize_vector(corner2);
dmnsn_object *box = dmnsn_new_cube();
- box->trans = dmnsn_scale_matrix(dmnsn_vector_construct((x2.x - x1.x)/2.0,
- (x2.y - x1.y)/2.0,
- (x2.z - x1.z)/2.0));
+ box->trans = dmnsn_scale_matrix(
+ dmnsn_vector_construct(fabs(x2.x - x1.x)/2.0,
+ fabs(x2.y - x1.y)/2.0,
+ fabs(x2.z - x1.z)/2.0)
+ );
box->trans = dmnsn_matrix_mul(
dmnsn_translation_matrix(dmnsn_vector_construct((x2.x + x1.x)/2.0,
(x2.y + x1.y)/2.0,