autoTableOfReal PCA_to_TableOfReal_reconstruct1 (PCA me, char32 *numstring) { try { long npc; autoNUMvector<double> pc (NUMstring_to_numbers (numstring, & npc), 1); autoConfiguration c = Configuration_create (1, npc); for (long j = 1; j <= npc; j++) { c -> data [1][j] = pc[j]; } autoTableOfReal him = PCA_and_Configuration_to_TableOfReal_reconstruct (me, c.get()); return him; } catch (MelderError) { Melder_throw (me, U" not reconstructed."); } }
Polygon Polygon_createSimple (wchar_t *xystring) { try { long numberOfPoints; autoNUMvector<double> xys (NUMstring_to_numbers (xystring, &numberOfPoints), 1); if (numberOfPoints < 6) { Melder_throw ("There must be at least 3 points (= x,y pairs) in the Polygon"); } if (numberOfPoints % 2 != 0) { Melder_throw ("One value is missing."); } numberOfPoints /= 2; // x,y pairs autoPolygon me = Polygon_create (numberOfPoints); for (long i = 1; i <= numberOfPoints; i++) { my x[i] = xys[2 * i - 1]; my y[i] = xys[2 * i]; if (i > 1 && my x[i] == my x[i - 1] && my y[i] == my y[i - 1]) { Melder_warning ("Two successives vertices are equal."); } } return me.transfer(); } catch (MelderError) { Melder_throw ("Polygon not created."); } }