From 6d3e9c207696a331da03a168a8dfa5a4a9d1e3bf Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 14 Jun 2009 18:17:57 +0000 Subject: New dmnsn_identity_matrix() function. --- libdimension/dimension/geometry.h | 3 ++- libdimension/geometry.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libdimension/dimension/geometry.h b/libdimension/dimension/geometry.h index fccd1bc..a2e54ab 100644 --- a/libdimension/dimension/geometry.h +++ b/libdimension/dimension/geometry.h @@ -51,9 +51,10 @@ dmnsn_matrix dmnsn_matrix_construct(double a0, double a1, double a2, double a3, double c0, double c1, double c2, double c3, double d0, double d1, double d2, double d3); +dmnsn_matrix dmnsn_identity_matrix(); dmnsn_matrix dmnsn_scale_matrix(dmnsn_vector s); dmnsn_matrix dmnsn_translation_matrix(dmnsn_vector d); -/* theta/|theta| = axis, |theta| = angle */ +/* Left-handed rotation; theta/|theta| = axis, |theta| = angle */ dmnsn_matrix dmnsn_rotation_matrix(dmnsn_vector theta); /* Vector and matrix arithmetic */ diff --git a/libdimension/geometry.c b/libdimension/geometry.c index a89fb9e..e9c2122 100644 --- a/libdimension/geometry.c +++ b/libdimension/geometry.c @@ -43,6 +43,17 @@ dmnsn_matrix_construct(double a0, double a1, double a2, double a3, return m; } +/* Identity matrix */ +dmnsn_matrix +dmnsn_identity_matrix() +{ + return dmnsn_matrix_construct(1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0); +} + +/* Scaling matrix */ dmnsn_matrix dmnsn_scale_matrix(dmnsn_vector s) { @@ -62,7 +73,7 @@ dmnsn_translation_matrix(dmnsn_vector d) 0.0, 0.0, 0.0, 1.0); } -/* Rotation matrix; theta/|theta| = axis, |theta| = angle */ +/* Left-handed rotation matrix; theta/|theta| = axis, |theta| = angle */ dmnsn_matrix dmnsn_rotation_matrix(dmnsn_vector theta) { -- cgit v1.2.3