dcm
Matrix.cpp@0:2b4ec92bff8b, 2014-02-20 (annotated)
- Committer:
- wisnup
- Date:
- Thu Feb 20 04:07:36 2014 +0000
- Revision:
- 0:2b4ec92bff8b
dcm
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wisnup | 0:2b4ec92bff8b | 1 | void Vector_Cross_Product(float C[3], float A[3], float B[3]) |
wisnup | 0:2b4ec92bff8b | 2 | { |
wisnup | 0:2b4ec92bff8b | 3 | C[0] = (A[1] * B[2]) - (A[2] * B[1]); |
wisnup | 0:2b4ec92bff8b | 4 | C[1] = (A[2] * B[0]) - (A[0] * B[2]); |
wisnup | 0:2b4ec92bff8b | 5 | C[2] = (A[0] * B[1]) - (A[1] * B[0]); |
wisnup | 0:2b4ec92bff8b | 6 | |
wisnup | 0:2b4ec92bff8b | 7 | return; |
wisnup | 0:2b4ec92bff8b | 8 | } |
wisnup | 0:2b4ec92bff8b | 9 | |
wisnup | 0:2b4ec92bff8b | 10 | void Vector_Scale(float C[3], float A[3], float b) |
wisnup | 0:2b4ec92bff8b | 11 | { |
wisnup | 0:2b4ec92bff8b | 12 | for (int m = 0; m < 3; m++) |
wisnup | 0:2b4ec92bff8b | 13 | C[m] = A[m] * b; |
wisnup | 0:2b4ec92bff8b | 14 | |
wisnup | 0:2b4ec92bff8b | 15 | return; |
wisnup | 0:2b4ec92bff8b | 16 | } |
wisnup | 0:2b4ec92bff8b | 17 | |
wisnup | 0:2b4ec92bff8b | 18 | float Vector_Dot_Product(float A[3], float B[3]) |
wisnup | 0:2b4ec92bff8b | 19 | { |
wisnup | 0:2b4ec92bff8b | 20 | float result = 0.0; |
wisnup | 0:2b4ec92bff8b | 21 | |
wisnup | 0:2b4ec92bff8b | 22 | for (int i = 0; i < 3; i++) { |
wisnup | 0:2b4ec92bff8b | 23 | result += A[i] * B[i]; |
wisnup | 0:2b4ec92bff8b | 24 | } |
wisnup | 0:2b4ec92bff8b | 25 | |
wisnup | 0:2b4ec92bff8b | 26 | return result; |
wisnup | 0:2b4ec92bff8b | 27 | } |
wisnup | 0:2b4ec92bff8b | 28 | |
wisnup | 0:2b4ec92bff8b | 29 | void Vector_Add(float C[3], float A[3], float B[3]) |
wisnup | 0:2b4ec92bff8b | 30 | { |
wisnup | 0:2b4ec92bff8b | 31 | for (int m = 0; m < 3; m++) |
wisnup | 0:2b4ec92bff8b | 32 | C[m] = A[m] + B[m]; |
wisnup | 0:2b4ec92bff8b | 33 | |
wisnup | 0:2b4ec92bff8b | 34 | return; |
wisnup | 0:2b4ec92bff8b | 35 | } |
wisnup | 0:2b4ec92bff8b | 36 | |
wisnup | 0:2b4ec92bff8b | 37 | void Vector_Add(float C[3][3], float A[3][3], float B[3][3]) |
wisnup | 0:2b4ec92bff8b | 38 | { |
wisnup | 0:2b4ec92bff8b | 39 | for (int m = 0; m < 3; m++) |
wisnup | 0:2b4ec92bff8b | 40 | for (int n = 0; n < 3; n++) |
wisnup | 0:2b4ec92bff8b | 41 | C[m][n] = A[m][n] + B[m][n]; |
wisnup | 0:2b4ec92bff8b | 42 | } |
wisnup | 0:2b4ec92bff8b | 43 | |
wisnup | 0:2b4ec92bff8b | 44 | void Matrix_Multiply(float C[3][3], float A[3][3], float B[3][3]) |
wisnup | 0:2b4ec92bff8b | 45 | { |
wisnup | 0:2b4ec92bff8b | 46 | for (int i = 0; i < 3; i++) { |
wisnup | 0:2b4ec92bff8b | 47 | for (int j = 0; j < 3; j++) { |
wisnup | 0:2b4ec92bff8b | 48 | C[i][j] = 0; |
wisnup | 0:2b4ec92bff8b | 49 | for (int k = 0; k < 3; k++) { |
wisnup | 0:2b4ec92bff8b | 50 | C[i][j] += A[i][k] * B[k][j]; |
wisnup | 0:2b4ec92bff8b | 51 | } |
wisnup | 0:2b4ec92bff8b | 52 | } |
wisnup | 0:2b4ec92bff8b | 53 | } |
wisnup | 0:2b4ec92bff8b | 54 | } |