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
00026
00027 class EXPCL_PANDA FLOATNAME(LMatrix3) {
00028 PUBLISHED:
00029 typedef const FLOATTYPE *iterator;
00030 typedef const FLOATTYPE *const_iterator;
00031
00032 INLINE_LINMATH FLOATNAME(LMatrix3)();
00033 INLINE_LINMATH FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) &other);
00034 INLINE_LINMATH FLOATNAME(LMatrix3) &operator = (const FLOATNAME(LMatrix3) &other);
00035 INLINE_LINMATH FLOATNAME(LMatrix3) &operator = (FLOATTYPE fill_value);
00036 INLINE_LINMATH FLOATNAME(LMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
00037 FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
00038 FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22);
00039
00040 void fill(FLOATTYPE fill_value);
00041 INLINE_LINMATH void set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02,
00042 FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12,
00043 FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22);
00044
00045 INLINE_LINMATH void set_row(int row, const FLOATNAME(LVecBase3) &v);
00046 INLINE_LINMATH void set_col(int col, const FLOATNAME(LVecBase3) &v);
00047
00048 INLINE_LINMATH void set_row(int row, const FLOATNAME(LVecBase2) &v);
00049 INLINE_LINMATH void set_col(int col, const FLOATNAME(LVecBase2) &v);
00050
00051 INLINE_LINMATH FLOATNAME(LVecBase3) get_row(int row) const;
00052 INLINE_LINMATH FLOATNAME(LVecBase3) get_col(int col) const;
00053
00054 INLINE_LINMATH FLOATNAME(LVecBase2) get_row2(int row) const;
00055 INLINE_LINMATH FLOATNAME(LVecBase2) get_col2(int col) const;
00056
00057
00058 INLINE_LINMATH void get_row(FLOATNAME(LVecBase3) &result_vec, int row) const;
00059
00060 INLINE_LINMATH FLOATTYPE &operator () (int row, int col);
00061 INLINE_LINMATH FLOATTYPE operator () (int row, int col) const;
00062
00063 INLINE_LINMATH bool is_nan() const;
00064
00065 INLINE_LINMATH FLOATTYPE get_cell(int row, int col) const;
00066 INLINE_LINMATH void set_cell(int row, int col, FLOATTYPE value);
00067
00068 INLINE_LINMATH const FLOATTYPE *get_data() const;
00069 INLINE_LINMATH int get_num_components() const;
00070
00071 public:
00072 INLINE_LINMATH iterator begin();
00073 INLINE_LINMATH iterator end();
00074
00075 INLINE_LINMATH const_iterator begin() const;
00076 INLINE_LINMATH const_iterator end() const;
00077
00078 PUBLISHED:
00079 INLINE_LINMATH bool operator < (const FLOATNAME(LMatrix3) &other) const;
00080 INLINE_LINMATH bool operator == (const FLOATNAME(LMatrix3) &other) const;
00081 INLINE_LINMATH bool operator != (const FLOATNAME(LMatrix3) &other) const;
00082
00083 INLINE_LINMATH int compare_to(const FLOATNAME(LMatrix3) &other) const;
00084 int compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const;
00085
00086 INLINE_LINMATH FLOATNAME(LVecBase3)
00087 xform(const FLOATNAME(LVecBase3) &v) const;
00088
00089 INLINE_LINMATH FLOATNAME(LVecBase2)
00090 xform_point(const FLOATNAME(LVecBase2) &v) const;
00091
00092 INLINE_LINMATH FLOATNAME(LVecBase2)
00093 xform_vec(const FLOATNAME(LVecBase2) &v) const;
00094
00095
00096 INLINE_LINMATH void multiply(const FLOATNAME(LMatrix3) &other1, const FLOATNAME(LMatrix3) &other2);
00097
00098 INLINE_LINMATH FLOATNAME(LMatrix3) operator * (const FLOATNAME(LMatrix3) &other) const;
00099 INLINE_LINMATH FLOATNAME(LMatrix3) operator * (FLOATTYPE scalar) const;
00100 INLINE_LINMATH FLOATNAME(LMatrix3) operator / (FLOATTYPE scalar) const;
00101
00102
00103 INLINE_LINMATH void scale_multiply(const FLOATNAME(LVecBase3) &scale_vector,const FLOATNAME(LMatrix3) &other_mat);
00104
00105 INLINE_LINMATH FLOATNAME(LMatrix3) &operator += (const FLOATNAME(LMatrix3) &other);
00106 INLINE_LINMATH FLOATNAME(LMatrix3) &operator -= (const FLOATNAME(LMatrix3) &other);
00107
00108 INLINE_LINMATH FLOATNAME(LMatrix3) &operator *= (const FLOATNAME(LMatrix3) &other);
00109
00110 INLINE_LINMATH FLOATNAME(LMatrix3) &operator *= (FLOATTYPE scalar);
00111 INLINE_LINMATH FLOATNAME(LMatrix3) &operator /= (FLOATTYPE scalar);
00112
00113 INLINE_LINMATH FLOATTYPE determinant() const;
00114
00115 INLINE_LINMATH void transpose_from(const FLOATNAME(LMatrix3) &other);
00116 INLINE_LINMATH void transpose_in_place();
00117
00118 INLINE_LINMATH bool invert_from(const FLOATNAME(LMatrix3) &other);
00119 INLINE_LINMATH bool invert_in_place();
00120
00121 static INLINE_LINMATH const FLOATNAME(LMatrix3) &ident_mat();
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 static INLINE_LINMATH FLOATNAME(LMatrix3)
00134 translate_mat(const FLOATNAME(LVecBase2) &trans);
00135 static INLINE_LINMATH FLOATNAME(LMatrix3)
00136 translate_mat(FLOATTYPE tx, FLOATTYPE ty);
00137 static INLINE_LINMATH FLOATNAME(LMatrix3)
00138 rotate_mat(FLOATTYPE angle);
00139 static INLINE_LINMATH FLOATNAME(LMatrix3)
00140 scale_mat(const FLOATNAME(LVecBase2) &scale);
00141 static INLINE_LINMATH FLOATNAME(LMatrix3)
00142 scale_mat(FLOATTYPE sx, FLOATTYPE sy);
00143
00144
00145
00146 static INLINE_LINMATH FLOATNAME(LMatrix3)
00147 rotate_mat(FLOATTYPE angle,
00148 FLOATNAME(LVecBase3) axis,
00149 CoordinateSystem cs = CS_default);
00150 static INLINE_LINMATH FLOATNAME(LMatrix3)
00151 rotate_mat_normaxis(FLOATTYPE angle,
00152 const FLOATNAME(LVecBase3) &axis,
00153 CoordinateSystem cs = CS_default);
00154
00155 static INLINE_LINMATH FLOATNAME(LMatrix3)
00156 scale_mat(const FLOATNAME(LVecBase3) &scale);
00157 static INLINE_LINMATH FLOATNAME(LMatrix3)
00158 scale_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz);
00159
00160 static const FLOATNAME(LMatrix3) &convert_mat(CoordinateSystem from,
00161 CoordinateSystem to);
00162
00163
00164
00165
00166
00167 bool almost_equal(const FLOATNAME(LMatrix3) &other,
00168 FLOATTYPE threshold) const;
00169
00170 INLINE_LINMATH bool almost_equal(const FLOATNAME(LMatrix3) &other) const;
00171
00172 void output(ostream &out) const;
00173 void write(ostream &out, int indent_level = 0) const;
00174
00175 public:
00176 INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const;
00177 void generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const;
00178
00179 public:
00180 union {
00181 struct {
00182 FLOATTYPE _00, _01, _02;
00183 FLOATTYPE _10, _11, _12;
00184 FLOATTYPE _20, _21, _22;
00185 } m;
00186
00187 FLOATTYPE data[3 * 3];
00188 } _m;
00189
00190 private:
00191 INLINE_LINMATH FLOATTYPE mult_cel(const FLOATNAME(LMatrix3) &other, int x, int y) const;
00192 INLINE_LINMATH FLOATTYPE det2(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e10, FLOATTYPE e11) const;
00193
00194 static const FLOATNAME(LMatrix3) _ident_mat;
00195 static const FLOATNAME(LMatrix3) _y_to_z_up_mat;
00196 static const FLOATNAME(LMatrix3) _z_to_y_up_mat;
00197 static const FLOATNAME(LMatrix3) _flip_y_mat;
00198 static const FLOATNAME(LMatrix3) _flip_z_mat;
00199 static const FLOATNAME(LMatrix3) _lz_to_ry_mat;
00200 static const FLOATNAME(LMatrix3) _ly_to_rz_mat;
00201
00202
00203 public:
00204 void write_datagram(Datagram& destination) const;
00205 void read_datagram(DatagramIterator& scan);
00206
00207 public:
00208 static TypeHandle get_class_type() {
00209 return _type_handle;
00210 }
00211 static void init_type();
00212
00213 private:
00214 static TypeHandle _type_handle;
00215 };
00216
00217
00218 INLINE_LINMATH ostream &operator << (ostream &out, const FLOATNAME(LMatrix3) &mat) {
00219 mat.output(out);
00220 return out;
00221 }
00222
00223 INLINE_LINMATH FLOATNAME(LMatrix3) transpose(const FLOATNAME(LMatrix3) &a);
00224 INLINE_LINMATH FLOATNAME(LMatrix3) invert(const FLOATNAME(LMatrix3) &a);
00225
00226 #include "lmatrix3_src.I"