00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 INLINE_LINMATH void
00026 compose_matrix(FLOATNAME(LMatrix4) &mat,
00027 const FLOATNAME(LVecBase3) &scale,
00028 const FLOATNAME(LVecBase3) &hpr,
00029 const FLOATNAME(LVecBase3) &translate,
00030 CoordinateSystem cs) {
00031 FLOATNAME(LMatrix3) upper3;
00032 compose_matrix(upper3, scale, hpr, cs);
00033 mat = FLOATNAME(LMatrix4)(upper3, translate);
00034 }
00035
00036 INLINE_LINMATH void
00037 compose_matrix(FLOATNAME(LMatrix4) &mat,
00038 const FLOATTYPE components[9],
00039 CoordinateSystem cs) {
00040 FLOATNAME(LVector3) scale(components[0],
00041 components[1],
00042 components[2]);
00043 FLOATNAME(LVector3) hpr(components[3],
00044 components[4],
00045 components[5]);
00046 FLOATNAME(LVector3) translate(components[6],
00047 components[7],
00048 components[8]);
00049 compose_matrix(mat, scale, hpr, translate, cs);
00050 }
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 INLINE_LINMATH bool
00062 decompose_matrix(const FLOATNAME(LMatrix4) &mat,
00063 FLOATNAME(LVecBase3) &scale,
00064 FLOATNAME(LVecBase3) &hpr,
00065 FLOATNAME(LVecBase3) &translate,
00066 CoordinateSystem cs) {
00067
00068 mat.get_row3(translate,3);
00069 return decompose_matrix(mat.get_upper_3(), scale, hpr, cs);
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 INLINE_LINMATH bool
00087 decompose_matrix(const FLOATNAME(LMatrix4) &mat,
00088 FLOATNAME(LVecBase3) &scale,
00089 FLOATNAME(LVecBase3) &hpr,
00090 FLOATNAME(LVecBase3) &translate,
00091 FLOATTYPE roll,
00092 CoordinateSystem cs) {
00093
00094 mat.get_row3(translate,3);
00095 return decompose_matrix(mat.get_upper_3(), scale, hpr, roll, cs);
00096 }
00097
00098 INLINE_LINMATH bool
00099 decompose_matrix(const FLOATNAME(LMatrix4) &mat,
00100 FLOATTYPE components[9],
00101 CoordinateSystem cs) {
00102 FLOATNAME(LVector3) scale, hpr, translate;
00103 if (!decompose_matrix(mat, scale, hpr, translate, cs)) {
00104 return false;
00105 }
00106 components[0] = scale[0];
00107 components[1] = scale[1];
00108 components[2] = scale[2];
00109 components[3] = hpr[0];
00110 components[4] = hpr[1];
00111 components[5] = hpr[2];
00112 components[6] = translate[0];
00113 components[7] = translate[1];
00114 components[8] = translate[2];
00115 return true;
00116 }