diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-04-17 14:26:19 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-04-17 14:26:19 -0400 |
commit | cd7cba285144211c5ea1f4573ad729555923dab1 (patch) | |
tree | 10f500a3c3fbbeba04778943fad36f97f6b2242f /libdimension | |
parent | bafe01580d1470f703a95a434b38998843440cd0 (diff) | |
download | dimension-cd7cba285144211c5ea1f4573ad729555923dab1.tar.xz |
Rename dmnsn_matrix_*_mul() to dmnsn_transform_*().
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/canvas_pigment.c | 2 | ||||
-rw-r--r-- | libdimension/csg.c | 12 | ||||
-rw-r--r-- | libdimension/cube.c | 6 | ||||
-rw-r--r-- | libdimension/dimension/geometry.h | 12 | ||||
-rw-r--r-- | libdimension/dimension/object.h | 2 | ||||
-rw-r--r-- | libdimension/geometry.c | 20 | ||||
-rw-r--r-- | libdimension/object.c | 8 | ||||
-rw-r--r-- | libdimension/perspective.c | 2 | ||||
-rw-r--r-- | libdimension/plane.c | 4 | ||||
-rw-r--r-- | libdimension/sphere.c | 8 |
10 files changed, 38 insertions, 38 deletions
diff --git a/libdimension/canvas_pigment.c b/libdimension/canvas_pigment.c index 8667e4d..c86fc66 100644 --- a/libdimension/canvas_pigment.c +++ b/libdimension/canvas_pigment.c @@ -40,7 +40,7 @@ dmnsn_new_canvas_pigment(dmnsn_canvas *canvas) static dmnsn_color dmnsn_canvas_pigment_fn(const dmnsn_pigment *pigment, dmnsn_vector v) { - v = dmnsn_matrix_vector_mul(pigment->trans_inv, v); + v = dmnsn_transform_vector(pigment->trans_inv, v); dmnsn_canvas *canvas = pigment->ptr; diff --git a/libdimension/csg.c b/libdimension/csg.c index 14f2980..1c5f15a 100644 --- a/libdimension/csg.c +++ b/libdimension/csg.c @@ -36,7 +36,7 @@ dmnsn_csg_union_intersection_fn(const dmnsn_object *csg, dmnsn_line line, dmnsn_intersection *intersection) { - dmnsn_line line_trans = dmnsn_matrix_line_mul(csg->trans_inv, line); + dmnsn_line line_trans = dmnsn_transform_line(csg->trans_inv, line); const dmnsn_object **params = csg->ptr; @@ -71,8 +71,8 @@ dmnsn_csg_union_intersection_fn(const dmnsn_object *csg, } intersection->ray = line; - intersection->normal = dmnsn_matrix_normal_mul(csg->trans, - intersection->normal); + intersection->normal = dmnsn_transform_normal(csg->trans, + intersection->normal); return true; } @@ -118,7 +118,7 @@ dmnsn_csg_intersection_fn(const dmnsn_object *csg, dmnsn_line line, /* inside1 is whether the second object is allowed inside the first object; respectively for inside2 */ - dmnsn_line line_trans = dmnsn_matrix_line_mul(csg->trans_inv, line); + dmnsn_line line_trans = dmnsn_transform_line(csg->trans_inv, line); const dmnsn_object **params = csg->ptr; @@ -183,8 +183,8 @@ dmnsn_csg_intersection_fn(const dmnsn_object *csg, dmnsn_line line, } intersection->ray = line; - intersection->normal = dmnsn_matrix_normal_mul(csg->trans, - intersection->normal); + intersection->normal = dmnsn_transform_normal(csg->trans, + intersection->normal); return true; } diff --git a/libdimension/cube.c b/libdimension/cube.c index dfd1757..396049d 100644 --- a/libdimension/cube.c +++ b/libdimension/cube.c @@ -49,7 +49,7 @@ static bool dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_line line, dmnsn_intersection *intersection) { - dmnsn_line line_trans = dmnsn_matrix_line_mul(cube->trans_inv, line); + dmnsn_line line_trans = dmnsn_transform_line(cube->trans_inv, line); double t = -1.0, t_temp; dmnsn_vector p, normal; @@ -125,7 +125,7 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_line line, if (t >= 0.0) { intersection->ray = line; intersection->t = t; - intersection->normal = dmnsn_matrix_normal_mul(cube->trans, normal); + intersection->normal = dmnsn_transform_normal(cube->trans, normal); intersection->texture = cube->texture; intersection->interior = cube->interior; return true; @@ -138,7 +138,7 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_line line, static bool dmnsn_cube_inside_fn(const dmnsn_object *cube, dmnsn_vector point) { - point = dmnsn_matrix_vector_mul(cube->trans_inv, point); + point = dmnsn_transform_vector(cube->trans_inv, 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; diff --git a/libdimension/dimension/geometry.h b/libdimension/dimension/geometry.h index 754e46d..a7ff32c 100644 --- a/libdimension/dimension/geometry.h +++ b/libdimension/dimension/geometry.h @@ -192,19 +192,19 @@ double dmnsn_vector_axis_angle(dmnsn_vector v1, dmnsn_vector v2, dmnsn_matrix dmnsn_matrix_inverse(dmnsn_matrix A); dmnsn_matrix dmnsn_matrix_mul(dmnsn_matrix lhs, dmnsn_matrix rhs); -dmnsn_vector dmnsn_matrix_vector_mul(dmnsn_matrix lhs, dmnsn_vector rhs); -dmnsn_bounding_box dmnsn_matrix_bounding_box_mul(dmnsn_matrix lhs, - dmnsn_bounding_box rhs); +dmnsn_vector dmnsn_transform_vector(dmnsn_matrix lhs, dmnsn_vector rhs); +dmnsn_bounding_box dmnsn_transform_bounding_box(dmnsn_matrix lhs, + dmnsn_bounding_box rhs); /* Affine line transformation; n = lhs*(x0 + n) - lhs*x0, x0 *= lhs */ DMNSN_INLINE dmnsn_line -dmnsn_matrix_line_mul(dmnsn_matrix lhs, dmnsn_line rhs) +dmnsn_transform_line(dmnsn_matrix lhs, dmnsn_line rhs) { /* 24 multiplications, 6 divisions, 30 additions */ dmnsn_line l; - l.x0 = dmnsn_matrix_vector_mul(lhs, rhs.x0); + l.x0 = dmnsn_transform_vector(lhs, rhs.x0); l.n = dmnsn_vector_sub( - dmnsn_matrix_vector_mul(lhs, dmnsn_vector_add(rhs.x0, rhs.n)), + dmnsn_transform_vector(lhs, dmnsn_vector_add(rhs.x0, rhs.n)), l.x0 ); return l; diff --git a/libdimension/dimension/object.h b/libdimension/dimension/object.h index 1d5f580..d0afa8a 100644 --- a/libdimension/dimension/object.h +++ b/libdimension/dimension/object.h @@ -41,7 +41,7 @@ typedef struct dmnsn_intersection { const dmnsn_interior *interior; } dmnsn_intersection; -dmnsn_vector dmnsn_matrix_normal_mul(dmnsn_matrix trans, dmnsn_vector normal); +dmnsn_vector dmnsn_transform_normal(dmnsn_matrix trans, dmnsn_vector normal); /* Forward-declare dmnsn_object */ typedef struct dmnsn_object dmnsn_object; diff --git a/libdimension/geometry.c b/libdimension/geometry.c index 304f21d..faeb30b 100644 --- a/libdimension/geometry.c +++ b/libdimension/geometry.c @@ -345,7 +345,7 @@ dmnsn_matrix_mul(dmnsn_matrix lhs, dmnsn_matrix rhs) /* Affine transformation; lhs*(x,y,z,1), normalized so the fourth element is 1 */ dmnsn_vector -dmnsn_matrix_vector_mul(dmnsn_matrix lhs, dmnsn_vector rhs) +dmnsn_transform_vector(dmnsn_matrix lhs, dmnsn_vector rhs) { /* 12 multiplications, 3 divisions, 12 additions */ dmnsn_vector r; @@ -361,7 +361,7 @@ dmnsn_matrix_vector_mul(dmnsn_matrix lhs, dmnsn_vector rhs) /* Give an axis-aligned box that contains the given box transformed by `lhs' */ dmnsn_bounding_box -dmnsn_matrix_bounding_box_mul(dmnsn_matrix trans, dmnsn_bounding_box box) +dmnsn_transform_bounding_box(dmnsn_matrix trans, dmnsn_bounding_box box) { /* Infinite bounding box support */ if (isinf(box.min.x) || isinf(box.min.y) || isinf(box.min.z) @@ -374,41 +374,41 @@ dmnsn_matrix_bounding_box_mul(dmnsn_matrix trans, dmnsn_bounding_box box) dmnsn_vector corner; dmnsn_bounding_box ret; - ret.min = dmnsn_matrix_vector_mul(trans, box.min); + ret.min = dmnsn_transform_vector(trans, box.min); ret.max = ret.min; corner = dmnsn_new_vector(box.min.x, box.min.y, box.max.z); - corner = dmnsn_matrix_vector_mul(trans, corner); + corner = dmnsn_transform_vector(trans, corner); ret.min = dmnsn_vector_min(ret.min, corner); ret.max = dmnsn_vector_max(ret.max, corner); corner = dmnsn_new_vector(box.min.x, box.max.y, box.min.z); - corner = dmnsn_matrix_vector_mul(trans, corner); + corner = dmnsn_transform_vector(trans, corner); ret.min = dmnsn_vector_min(ret.min, corner); ret.max = dmnsn_vector_max(ret.max, corner); corner = dmnsn_new_vector(box.min.x, box.max.y, box.max.z); - corner = dmnsn_matrix_vector_mul(trans, corner); + corner = dmnsn_transform_vector(trans, corner); ret.min = dmnsn_vector_min(ret.min, corner); ret.max = dmnsn_vector_max(ret.max, corner); corner = dmnsn_new_vector(box.max.x, box.min.y, box.min.z); - corner = dmnsn_matrix_vector_mul(trans, corner); + corner = dmnsn_transform_vector(trans, corner); ret.min = dmnsn_vector_min(ret.min, corner); ret.max = dmnsn_vector_max(ret.max, corner); corner = dmnsn_new_vector(box.max.x, box.min.y, box.max.z); - corner = dmnsn_matrix_vector_mul(trans, corner); + corner = dmnsn_transform_vector(trans, corner); ret.min = dmnsn_vector_min(ret.min, corner); ret.max = dmnsn_vector_max(ret.max, corner); corner = dmnsn_new_vector(box.max.x, box.max.y, box.min.z); - corner = dmnsn_matrix_vector_mul(trans, corner); + corner = dmnsn_transform_vector(trans, corner); ret.min = dmnsn_vector_min(ret.min, corner); ret.max = dmnsn_vector_max(ret.max, corner); corner = dmnsn_new_vector(box.max.x, box.max.y, box.max.z); - corner = dmnsn_matrix_vector_mul(trans, corner); + corner = dmnsn_transform_vector(trans, corner); ret.min = dmnsn_vector_min(ret.min, corner); ret.max = dmnsn_vector_max(ret.max, corner); diff --git a/libdimension/object.c b/libdimension/object.c index 3cf68c7..981e535 100644 --- a/libdimension/object.c +++ b/libdimension/object.c @@ -21,12 +21,12 @@ #include "dimension.h" dmnsn_vector -dmnsn_matrix_normal_mul(dmnsn_matrix trans, dmnsn_vector normal) +dmnsn_transform_normal(dmnsn_matrix trans, dmnsn_vector normal) { return dmnsn_vector_normalize( dmnsn_vector_sub( - dmnsn_matrix_vector_mul(trans, normal), - dmnsn_matrix_vector_mul(trans, dmnsn_zero) + dmnsn_transform_vector(trans, normal), + dmnsn_transform_vector(trans, dmnsn_zero) ) ); } @@ -62,7 +62,7 @@ void dmnsn_object_precompute(dmnsn_object *object) { object->bounding_box - = dmnsn_matrix_bounding_box_mul(object->trans, object->bounding_box); + = dmnsn_transform_bounding_box(object->trans, object->bounding_box); object->trans_inv = dmnsn_matrix_inverse(object->trans); if (object->texture) { object->texture->trans diff --git a/libdimension/perspective.c b/libdimension/perspective.c index 9c2f31d..017d215 100644 --- a/libdimension/perspective.c +++ b/libdimension/perspective.c @@ -76,5 +76,5 @@ dmnsn_perspective_camera_ray_fn(const dmnsn_camera *camera, /* Aim at the z = 1 plane */ l.n = dmnsn_new_vector(x - 0.5, y - 0.5, 1.0); - return dmnsn_matrix_line_mul(*trans, l); + return dmnsn_transform_line(*trans, l); } diff --git a/libdimension/plane.c b/libdimension/plane.c index e475c46..1680aa0 100644 --- a/libdimension/plane.c +++ b/libdimension/plane.c @@ -58,14 +58,14 @@ dmnsn_plane_intersection_fn(const dmnsn_object *plane, dmnsn_line line, { dmnsn_vector *normal = plane->ptr; - dmnsn_line line_trans = dmnsn_matrix_line_mul(plane->trans_inv, line); + dmnsn_line line_trans = dmnsn_transform_line(plane->trans_inv, line); double den = dmnsn_vector_dot(line_trans.n, *normal); if (den != 0.0) { double t = -dmnsn_vector_dot(line_trans.x0, *normal)/den; if (t >= 0.0) { intersection->ray = line; intersection->t = t; - intersection->normal = dmnsn_matrix_normal_mul(plane->trans, *normal); + intersection->normal = dmnsn_transform_normal(plane->trans, *normal); intersection->texture = plane->texture; intersection->interior = plane->interior; return true; diff --git a/libdimension/sphere.c b/libdimension/sphere.c index 94ae44e..d384e60 100644 --- a/libdimension/sphere.c +++ b/libdimension/sphere.c @@ -50,7 +50,7 @@ static bool dmnsn_sphere_intersection_fn(const dmnsn_object *sphere, dmnsn_line line, dmnsn_intersection *intersection) { - dmnsn_line l = dmnsn_matrix_line_mul(sphere->trans_inv, line); + dmnsn_line l = dmnsn_transform_line(sphere->trans_inv, line); /* Solve (x0 + nx*t)^2 + (y0 + ny*t)^2 + (z0 + nz*t)^2 == 1 */ double a, b, c, t; @@ -67,8 +67,8 @@ dmnsn_sphere_intersection_fn(const dmnsn_object *sphere, dmnsn_line line, if (t >= 0.0) { intersection->ray = line; intersection->t = t; - intersection->normal = dmnsn_matrix_normal_mul(sphere->trans, - dmnsn_line_point(l, t)); + intersection->normal = dmnsn_transform_normal(sphere->trans, + dmnsn_line_point(l, t)); intersection->texture = sphere->texture; intersection->interior = sphere->interior; return true; @@ -82,6 +82,6 @@ dmnsn_sphere_intersection_fn(const dmnsn_object *sphere, dmnsn_line line, static bool dmnsn_sphere_inside_fn(const dmnsn_object *sphere, dmnsn_vector point) { - point = dmnsn_matrix_vector_mul(sphere->trans_inv, point); + point = dmnsn_transform_vector(sphere->trans_inv, point); return point.x*point.x + point.y*point.y + point.z*point.z < 1.0; } |