|
35 | 35 | package net.imglib2.algorithm.kdtree; |
36 | 36 |
|
37 | 37 | import net.imglib2.AbstractEuclideanSpace; |
38 | | -import net.imglib2.realtransform.AffineTransform3D; |
| 38 | +import net.imglib2.realtransform.AffineGet; |
39 | 39 | import net.imglib2.util.LinAlgHelpers; |
40 | 40 |
|
41 | 41 | public class HyperPlane extends AbstractEuclideanSpace |
@@ -72,28 +72,30 @@ public double getDistance() |
72 | 72 | } |
73 | 73 |
|
74 | 74 | /** |
75 | | - * Apply an {@link AffineTransform3D} to a 3D {@link HyperPlane}. |
| 75 | + * Apply an {@link AffineGet affine transformation} to a {@link HyperPlane}. |
76 | 76 | * |
77 | 77 | * @param plane |
78 | | - * a 3D plane. |
| 78 | + * a plane. |
79 | 79 | * @param transform |
80 | 80 | * affine transformation to apply to the plane. |
81 | 81 | * @return the transformed plane. |
82 | 82 | */ |
83 | | - public static HyperPlane transform( final HyperPlane plane, final AffineTransform3D transform ) |
| 83 | + public static HyperPlane transform( final HyperPlane plane, final AffineGet transform ) |
84 | 84 | { |
85 | | - assert plane.numDimensions() == 3; |
| 85 | + assert plane.numDimensions() == transform.numDimensions(); |
86 | 86 |
|
87 | | - final double[] O = new double[ 3 ]; |
88 | | - final double[] tO = new double[ 3 ]; |
| 87 | + final int n = transform.numDimensions(); |
| 88 | + |
| 89 | + final double[] O = new double[ n ]; |
| 90 | + final double[] tO = new double[ n ]; |
89 | 91 | LinAlgHelpers.scale( plane.getNormal(), plane.getDistance(), O ); |
90 | 92 | transform.apply( O, tO ); |
91 | 93 |
|
92 | | - final double[][] m = new double[ 3 ][ 3 ]; |
93 | | - for ( int r = 0; r < 3; ++r ) |
94 | | - for ( int c = 0; c < 3; ++c ) |
| 94 | + final double[][] m = new double[ n ][ n ]; |
| 95 | + for ( int r = 0; r < n; ++r ) |
| 96 | + for ( int c = 0; c < n; ++c ) |
95 | 97 | m[ r ][ c ] = transform.inverse().get( c, r ); |
96 | | - final double[] tN = new double[ 3 ]; |
| 98 | + final double[] tN = new double[ n ]; |
97 | 99 | LinAlgHelpers.mult( m, plane.getNormal(), tN ); |
98 | 100 | LinAlgHelpers.normalize( tN ); |
99 | 101 | final double td = LinAlgHelpers.dot( tN, tO ); |
|
0 commit comments