goffice r2112 - in trunk: . goffice/math
- From: jbrefort svn gnome org
- To: svn-commits-list gnome org
- Subject: goffice r2112 - in trunk: . goffice/math
- Date: Sat, 21 Jun 2008 11:18:07 +0000 (UTC)
Author: jbrefort
Date: Sat Jun 21 11:18:07 2008
New Revision: 2112
URL: http://svn.gnome.org/viewvc/goffice?rev=2112&view=rev
Log:
2008-06-21 Jean Brefort <jean brefort normalesup org>
* goffice/math/go-matrix3x3.c:
(go_matrix3x3_from_euler_transposed), (go_matrix3x3_to_euler),
(go_matrix3x3_multiply): add missing functions.
* goffice/math/go-matrix3x3.h: ditto.
Modified:
trunk/ChangeLog
trunk/goffice/math/go-matrix3x3.c
trunk/goffice/math/go-matrix3x3.h
Modified: trunk/goffice/math/go-matrix3x3.c
==============================================================================
--- trunk/goffice/math/go-matrix3x3.c (original)
+++ trunk/goffice/math/go-matrix3x3.c Sat Jun 21 11:18:07 2008
@@ -54,3 +54,84 @@
mat->a32 = st * cf;
mat->a33 = ct;
}
+
+void
+go_matrix3x3_from_euler_transposed (GOMatrix3x3 *mat,
+ double Psi, double Theta, double Phi)
+{
+ gdouble sp = sin(Psi);
+ gdouble cp = cos(Psi);
+ gdouble st = sin(Theta);
+ gdouble ct = cos(Theta);
+ gdouble sf = sin(Phi);
+ gdouble cf = cos(Phi);
+ mat->a11 = cf * cp - sf * sp * ct;
+ mat->a21 = - cp * sf - sp * cf * ct;
+ mat->a31 = st * sp;
+ mat->a12 = sp * cf + cp * sf * ct;
+ mat->a22 = cf * cp * ct - sf * sp;
+ mat->a32 = - st * cp;
+ mat->a13 = st * sf;
+ mat->a23 = st * cf;
+ mat->a33 = ct;
+}
+
+#define MATRIX_THRESHOLD .999999999
+void
+go_matrix3x3_to_euler (GOMatrix3x3 const *mat,
+ double *Psi, double *Theta, double *Phi)
+{
+ if (fabs(mat->a33) > MATRIX_THRESHOLD) {
+ *Theta = (mat->a33 > 0.) ? 0. : 2 * M_PI;
+ *Psi = 0.;
+ if (fabs(mat->a11) > MATRIX_THRESHOLD)
+ *Phi = (mat->a11 > 0.) ? 0. : 2 * M_PI;
+ else
+ *Phi = (mat->a21 > 0.) ? acos(mat->a11) : - acos(mat->a11);
+ } else {
+ double st, si, co;
+ *Theta = acos(mat->a33);
+ st = sin(*Theta);
+ si = mat->a13 / st;
+ co = - mat->a23 / st;;
+ if (fabs(co) > MATRIX_THRESHOLD)
+ *Psi = (co > 0.) ? 0. : 2 * M_PI;
+ else
+ *Psi = (si > 0.) ? acos(co) : - acos(co);
+ si = mat->a31 / st;
+ co = mat->a32 / st;
+ if (fabs(co) > MATRIX_THRESHOLD)
+ *Phi = (co > 0.) ? 0. : 2 * M_PI;
+ else
+ *Phi = (si > 0.) ? acos(co) : - acos(co);
+ }
+}
+
+void
+go_matrix3x3_multiply (GOMatrix3x3 *dest,
+ GOMatrix3x3 const *src1, GOMatrix3x3 const *src2)
+{
+ double a11, a12, a13, a21, a22, a23, a31, a32, a33;
+
+ if (!dest || !src1 || !src2)
+ return;
+
+ a11 = src1->a11 * src2->a11 + src1->a12 * src2->a21 + src1->a13 * src2->a31;
+ a12 = src1->a11 * src2->a12 + src1->a12 * src2->a22 + src1->a13 * src2->a32;
+ a13 = src1->a11 * src2->a13 + src1->a12 * src2->a23 + src1->a13 * src2->a33;
+ a21 = src1->a21 * src2->a11 + src1->a22 * src2->a21 + src1->a23 * src2->a31;
+ a22 = src1->a21 * src2->a12 + src1->a22 * src2->a22 + src1->a23 * src2->a32;
+ a23 = src1->a21 * src2->a13 + src1->a22 * src2->a23 + src1->a23 * src2->a33;
+ a31 = src1->a31 * src2->a11 + src1->a32 * src2->a21 + src1->a33 * src2->a31;
+ a32 = src1->a31 * src2->a12 + src1->a32 * src2->a22 + src1->a33 * src2->a32;
+ a33 = src1->a31 * src2->a13 + src1->a32 * src2->a23 + src1->a33 * src2->a33;
+ dest->a11 = a11;
+ dest->a12 = a12;
+ dest->a13 = a13;
+ dest->a21 = a21;
+ dest->a22 = a22;
+ dest->a23 = a23;
+ dest->a31 = a31;
+ dest->a32 = a32;
+ dest->a33 = a33;
+}
Modified: trunk/goffice/math/go-matrix3x3.h
==============================================================================
--- trunk/goffice/math/go-matrix3x3.h (original)
+++ trunk/goffice/math/go-matrix3x3.h Sat Jun 21 11:18:07 2008
@@ -30,10 +30,19 @@
} GOMatrix3x3;
void go_matrix3x3_transform (GOMatrix3x3 *mat,
- gdouble xo, gdouble yo, gdouble zo,
- gdouble *x, gdouble *y, gdouble *z);
+ double xo, double yo, double zo,
+ double *x, double *y, double *z);
void go_matrix3x3_from_euler (GOMatrix3x3 *mat,
- gdouble Psi, gdouble Theta, gdouble Phi);
+ double Psi, double Theta, double Phi);
+
+void go_matrix3x3_from_euler_transposed (GOMatrix3x3 *mat,
+ double Psi, double Theta, double Phi);
+
+void go_matrix3x3_to_euler (GOMatrix3x3 const *mat,
+ double *Psi, double *Theta, double *Phi);
+
+void go_matrix3x3_multiply (GOMatrix3x3 *dest,
+ GOMatrix3x3 const *src1, GOMatrix3x3 const *src2);
#endif /* GO_MATRIX3X3_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]