lcsim/src/org/lcsim/contrib/onoprien/tracking/transform
diff -u -r1.1 -r1.2
--- Rotation3D.java 7 May 2007 19:02:44 -0000 1.1
+++ Rotation3D.java 8 May 2007 02:02:42 -0000 1.2
@@ -13,7 +13,7 @@
* An object of this type defines a reference frame rotation in 3D space.
*
* @author D.Onoprienko
- * @version $Id: Rotation3D.java,v 1.1 2007/05/07 19:02:44 onoprien Exp $
+ * @version $Id: Rotation3D.java,v 1.2 2007/05/08 02:02:42 onoprien Exp $
*/
public class Rotation3D implements Transformation3D {
@@ -88,8 +88,21 @@
* covariance matrix in the original reference frame.
*/
public SymmetricMatrix transformTo(SymmetricMatrix covMatrix) {
- System.out.println("Covariance matrix transformation is not yet implemented");
- return null;
+ if (_to == null) _to = VecOp.inverse(_from);
+ double[] loc = new double[6];
+ int index = -1;
+ for (int l = 0; l <3; l++) {
+ for (int k = 0; k <= l; k++) {
+ loc[++index] = 0.;
+ for (int i = 0; i<3; i++) {
+ for (int j = 0; j<= i; j++) {
+ double term = _to.e(l,i)*_to.e(k,j)*covMatrix.e(i,j);
+ loc[index] += (i==j) ? term : 2.*term;
+ }
+ }
+ }
+ }
+ return new SymmetricMatrix(3, loc, true);
}
/**
@@ -97,8 +110,21 @@
* covariance matrix in the transformed reference frame.
*/
public SymmetricMatrix transformFrom(SymmetricMatrix covMatrix) {
- System.out.println("Covariance matrix transformation is not yet implemented");
- return null;
+ if (_from == null) _from = VecOp.inverse(_to);
+ double[] glob = new double[6];
+ int index = -1;
+ for (int l = 0; l <3; l++) {
+ for (int k = 0; k <= l; k++) {
+ glob[++index] = 0.;
+ for (int i = 0; i<3; i++) {
+ for (int j = 0; j<= i; j++) {
+ double term = _from.e(l,i)*_from.e(k,j)*covMatrix.e(i,j);
+ glob[index] += (i==j) ? term : 2.*term;
+ }
+ }
+ }
+ }
+ return new SymmetricMatrix(3, glob, true);
}
// -- Private parts : ---------------------------------------------------------