home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Peter's Final Project / src / matrix.vector.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-10  |  2.7 KB  |  87 lines  |  [TEXT/KAHL]

  1. /*
  2.  *  Peter's Final Project -- A texture mapping demonstration
  3.  *  © 1995, Peter Mattis
  4.  *
  5.  *  E-mail:
  6.  *  petm@soda.csua.berkeley.edu
  7.  *
  8.  *  Snail-mail:
  9.  *   Peter Mattis
  10.  *   557 Fort Laramie Dr.
  11.  *   Sunnyvale, CA 94087
  12.  *
  13.  *  Avaible from:
  14.  *  http://www.csua.berkeley.edu/~petm/final.html
  15.  *
  16.  *  This program is free software; you can redistribute it and/or modify
  17.  *  it under the terms of the GNU General Public License as published by
  18.  *  the Free Software Foundation; either version 2 of the License, or
  19.  *  (at your option) any later version.
  20.  *
  21.  *  This program is distributed in the hope that it will be useful,
  22.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  23.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24.  *  GNU General Public License for more details.
  25.  *
  26.  *  You should have received a copy of the GNU General Public License
  27.  *  along with this program; if not, write to the Free Software
  28.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29.  */
  30.  
  31. #ifndef __MATRIX_VECTOR_H__
  32. #define __MATRIX_VECTOR_H__
  33.  
  34. #include "type.defs.h"
  35.  
  36. void matrix_describe (MATRIX);
  37.  
  38. void matrix_clear (MATRIX);
  39. void matrix_copy (MATRIX, MATRIX);
  40. void matrix_multiply (MATRIX, NUM);
  41. void matrix_translate (MATRIX, NUM, NUM, NUM);
  42. void matrix_scale (MATRIX, NUM, NUM, NUM);
  43. void matrix_rotate_x (MATRIX, NUM);
  44. void matrix_rotate_y (MATRIX, NUM);
  45. void matrix_rotate_z (MATRIX, NUM);
  46. void matrix_projection (MATRIX, NUM);
  47. void matrix_compose (MATRIX, MATRIX, MATRIX);
  48. void matrix_vector (MATRIX, VECTOR, VECTOR);
  49.  
  50. void matrix_transpose (MATRIX, MATRIX);
  51. void matrix_inverse (MATRIX, MATRIX);
  52. void matrix_adjoint (MATRIX, MATRIX);
  53. NUM matrix_determinant4x4 (MATRIX);
  54. NUM matrix_determinant3x3 (
  55.                 NUM, NUM, NUM,
  56.                 NUM, NUM, NUM,
  57.                 NUM, NUM, NUM);
  58. NUM matrix_determinant2x2 (
  59.                 NUM, NUM,
  60.                 NUM, NUM);
  61.  
  62. void vector_clear (VECTOR);
  63. void vector_add (VECTOR, VECTOR, VECTOR);
  64. void vector_sub (VECTOR, VECTOR, VECTOR);
  65. void vector_mul (VECTOR, NUM, VECTOR);
  66. void vector_copy (VECTOR, VECTOR);
  67. NUM vector_dot (VECTOR, VECTOR);
  68. void vector_cross (VECTOR, VECTOR, VECTOR);
  69. NUM vector_magnitude (VECTOR);
  70. void vector_normalize (VECTOR);
  71. void vector_homogenize (VECTOR);
  72.  
  73. #define matrix_element(m, i, j)          ((m)[i][j])
  74. #define set_matrix_element(m, i, j, k)   (matrix_element(m, i, j) = (k))
  75.  
  76. #define vector_x(v)            ((v)[0])
  77. #define vector_y(v)            ((v)[1])
  78. #define vector_z(v)            ((v)[2])
  79. #define vector_w(v)            ((v)[3])
  80.  
  81. #define set_vector_x(v, k)     (vector_x(v) = (k))
  82. #define set_vector_y(v, k)     (vector_y(v) = (k))
  83. #define set_vector_z(v, k)     (vector_z(v) = (k))
  84. #define set_vector_w(v, k)     (vector_w(v) = (k))
  85.  
  86. #endif /* __MATRIX_VECTOR_H__ */
  87.