diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-09-03 15:55:19 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-10-25 11:03:56 -0400 |
commit | b554b20c8d59d6046bdcec7c79fb61cd0e65811c (patch) | |
tree | a6c6f257cfaffcec953be7c0cce180f7a8855c68 /libdimension/model/objects/cube.c | |
parent | b2cf35c26d5263f3079480208429e3a1d7dd2373 (diff) | |
download | dimension-b554b20c8d59d6046bdcec7c79fb61cd0e65811c.tar.xz |
math: Make vectors have an array instead of different fields.
Diffstat (limited to 'libdimension/model/objects/cube.c')
-rw-r--r-- | libdimension/model/objects/cube.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libdimension/model/objects/cube.c b/libdimension/model/objects/cube.c index 7d6fe0f..0434d89 100644 --- a/libdimension/model/objects/cube.c +++ b/libdimension/model/objects/cube.c @@ -23,6 +23,7 @@ * Cubes. */ +#include "internal.h" #include "dimension/model.h" #include <math.h> @@ -36,8 +37,8 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_ray ray, dmnsn_vector nmin, nmax; double tmin, tmax; - double tx1 = (-1.0 - ray.x0.x)/ray.n.x; - double tx2 = (+1.0 - ray.x0.x)/ray.n.x; + double tx1 = (-1.0 - ray.x0.X)/ray.n.X; + double tx2 = (+1.0 - ray.x0.X)/ray.n.X; if (tx1 < tx2) { tmin = tx1; @@ -54,8 +55,8 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_ray ray, if (tmin > tmax) return false; - double ty1 = (-1.0 - ray.x0.y)/ray.n.y; - double ty2 = (+1.0 - ray.x0.y)/ray.n.y; + double ty1 = (-1.0 - ray.x0.Y)/ray.n.Y; + double ty2 = (+1.0 - ray.x0.Y)/ray.n.Y; if (ty1 < ty2) { if (ty1 > tmin) { @@ -80,8 +81,8 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_ray ray, if (tmin > tmax) return false; - double tz1 = (-1.0 - ray.x0.z)/ray.n.z; - double tz2 = (+1.0 - ray.x0.z)/ray.n.z; + double tz1 = (-1.0 - ray.x0.Z)/ray.n.Z; + double tz2 = (+1.0 - ray.x0.Z)/ray.n.Z; if (tz1 < tz2) { if (tz1 > tmin) { @@ -124,9 +125,9 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_ray ray, static bool dmnsn_cube_inside_fn(const dmnsn_object *cube, dmnsn_vector point) { - return point.x > -1.0 && point.x < 1.0 - && point.y > -1.0 && point.y < 1.0 - && point.z > -1.0 && point.z < 1.0; + return point.X > -1.0 && point.X < 1.0 + && point.Y > -1.0 && point.Y < 1.0 + && point.Z > -1.0 && point.Z < 1.0; } /// Boundary callback for a cube. |