File tree Expand file tree Collapse file tree
src/main/java/sc/fiji/snt/analysis Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222
2323package sc .fiji .snt .analysis ;
2424
25+ import net .imagej .mesh .Vertex ;
26+ import net .imagej .mesh .Vertices ;
2527import org .apache .commons .math3 .linear .Array2DRowRealMatrix ;
2628import org .apache .commons .math3 .linear .EigenDecomposition ;
2729import org .apache .commons .math3 .linear .RealMatrix ;
3335
3436import java .util .ArrayList ;
3537import java .util .Collection ;
38+ import java .util .Iterator ;
3639import java .util .List ;
3740
3841/**
@@ -95,6 +98,21 @@ public static PrincipalAxis[] getPrincipalAxes(final Path path) {
9598 return getPrincipalAxes (path .getNodes ());
9699 }
97100
101+ /**
102+ * Computes the principal axes from the vertices of a mesh
103+ *
104+ * @param vertices the collection of vertices to analyze
105+ * @return array of three PrincipalAxis objects ordered by decreasing variance
106+ * (primary, secondary, tertiary), or null if computation fails
107+ */
108+ public static PrincipalAxis [] getPrincipalAxes (final Vertices vertices ) {
109+ final List <SNTPoint > points = new ArrayList <>((int )vertices .size ());
110+ for (final Vertex vertex : vertices ) {
111+ points .add (SNTPoint .of (vertex .x (), vertex .y (), vertex .z ()));
112+ }
113+ return getPrincipalAxes (points );
114+ }
115+
98116 /**
99117 * Computes the principal axes for a collection of SNTPoints.
100118 *
You can’t perform that action at this time.
0 commit comments