summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-07-03 22:22:18 -0600
committerTavian Barnes <tavianator@gmail.com>2010-07-03 22:22:18 -0600
commit2b5d6e5f42f625049e3f9df765e0cf3fbecc6520 (patch)
treea43683254aec4fafe544f4a1cab289b96922c0f6 /libdimension
parent66c4b24d561b643e8ccba74bf78223fdefe524fe (diff)
downloaddimension-2b5d6e5f42f625049e3f9df765e0cf3fbecc6520.tar.xz
Make dmnsn_perspective_camera_ray_fn() more idiomatic.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/perspective.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/libdimension/perspective.c b/libdimension/perspective.c
index aba3a97..02f6c7c 100644
--- a/libdimension/perspective.c
+++ b/libdimension/perspective.c
@@ -30,7 +30,7 @@ static dmnsn_line dmnsn_perspective_camera_ray_fn(const dmnsn_camera *camera,
double x, double y);
/* Create a new perspective camera. Rays are aimed from the origin to a screen
- located on the z = 1 frame, from (-0.5, -0.5) to (0.5, 0.5). Rays are then
+ located on the z = 1 plane, from (-0.5, -0.5) to (0.5, 0.5). Rays are then
transformed by the camera's transformation matrix. */
dmnsn_camera *
dmnsn_new_perspective_camera()
@@ -69,13 +69,9 @@ dmnsn_perspective_camera_ray_fn(const dmnsn_camera *camera,
double x, double y)
{
dmnsn_matrix *trans = camera->ptr;
- dmnsn_line l;
-
- /* Rays originate at the origin, oddly enough */
- l.x0 = dmnsn_new_vector(0.0, 0.0, 0.0);
-
- /* Aim at the z = 1 plane */
- l.n = dmnsn_new_vector(x - 0.5, y - 0.5, 1.0);
-
+ dmnsn_line l = dmnsn_new_line(
+ dmnsn_zero,
+ dmnsn_new_vector(x - 0.5, y - 0.5, 1.0)
+ );
return dmnsn_transform_line(*trans, l);
}