/* power transform */ static void reset_exp(xgobidata *xg) { char lbl[32]; Boolean state; int j, k, groupno; int tfno = POWER; /* reset the power label */ sprintf(lbl, "%4.2f", exponent); XtVaSetValues(exponent_lbl, XtNlabel, lbl, NULL); ntform_cols = 0; for (j=0; j<xg->ncols-1; j++) { XtVaGetValues(var_cbox[j], XtNstate, &state, NULL); if (state) { tform_cols[ntform_cols++] = j; groupno = xg->vgroup_ids[j]; for (k=j+1; k<xg->ncols-1; k++) { if (xg->vgroup_ids[k] == groupno) tform_cols[ntform_cols++] = k; } } } if (ntform_cols > 0) { if (transform1(xg, tform_cols, ntform_cols, &domain_incr, domain_adj, inv_domain_adj, tfno, (double) exponent)) { tform_response(xg, tform_cols, ntform_cols); } } }
/* ARGSUSED */ static XtCallbackProc stage1_tform_cback(Widget w, xgobidata *xg, XtPointer cbdata) { int tfno, j /*, k, groupno*/; Boolean state; for (tfno=0; tfno<N1TFORMS; tfno++) if (w == stage1_tform_cmd[tfno]) break; ntform_cols = 0; for (j=0; j<xg->ncols-1; j++) { XtVaGetValues(var_cbox[j], XtNstate, &state, NULL); if (state) { tform_cols[ntform_cols++] = j; /* groupno = xg->vgroup_ids[j]; for (k=j+1; k<xg->ncols-1; k++) { if (xg->vgroup_ids[k] == groupno) tform_cols[ntform_cols++] = k; }*/ } } if (ntform_cols > 0) { if (transform1(xg, tform_cols, ntform_cols, &domain_incr, domain_adj, inv_domain_adj, tfno, (double) exponent)) { tform_response(xg, tform_cols, ntform_cols); } } }
void restore_variables(xgobidata *xg) { if (ntform_cols > 0 && tform_cols != NULL) { if ( transform1(xg, tform_cols, ntform_cols, &domain_incr, domain_adj, inv_domain_adj, RESTORE, 0.0) ) { tform_response(xg, tform_cols, ntform_cols); } } }
unsigned long int transform(char *str1, char *str2, int n, int type,int *arr1,int *arr2){ unsigned long int score = 0; switch(type){ case 0: score = transform0(str1, str2, n, type); break; case 1: score = transform1(str1, str2, n, type, arr1, arr2); break; } return score; }
/* This is only stage1 so far */ void transform_all(xgobidata *xg) { int j, cols[1]; for (j=0; j<xg->ncols-1; j++) { cols[0] = j; if (tform_tp != (TFormType *) NULL && &tform_tp[j] != (TFormType *) NULL) transform1(xg, cols, 1, &tform_tp[j].domain_incr, tform_tp[j].domain_adj, tform_tp[j].inv_domain_adj, tform_tp[j].tform1, tform_tp[j].param); } }
SCM pip_color_distance (SCM cR, SCM cG, SCM cB, SCM cR2, SCM cG2, SCM cB2) { double R = scm_to_double (cR); double G = scm_to_double (cG); double B = scm_to_double (cB); double R2 = scm_to_double (cR2); double G2 = scm_to_double (cG2); double B2 = scm_to_double (cB2); R /= 255.0; G /= 255.0; B /= 255.0; R2 /= 255.0; G2 /= 255.0; B2 /= 255.0; R = transform1 (R); G = transform1 (G); B = transform1 (B); R2 = transform1 (R2); G2 = transform1 (G2); B2 = transform1 (B2); double X = R * 0.4124 + G * 0.3576 + B * 0.1805; double Y = R * 0.2126 + G * 0.7152 + B * 0.0722; double Z = R * 0.0193 + G * 0.1192 + B * 0.9505; double X2 = R2 * 0.4124 + G2 * 0.3576 + B2 * 0.1805; double Y2 = R2 * 0.2126 + G2 * 0.7152 + B2 * 0.0722; double Z2 = R2 * 0.0193 + G2 * 0.1192 + B2 * 0.9505; Y /= REFY; Z /= REFZ; X /= REFX; Y2 /= REFY; Z2 /= REFZ; X2 /= REFX; double LL = 116.0 * transform2(Y) - 16.0; double AA = 500.0 * (transform2(X) - transform2 (Y)); double BB = 200.0 * (transform2(Y) - transform2 (Z)); double LL2 = 116.0 * transform2(Y2) - 16.0; double AA2 = 500.0 * (transform2(X2) - transform2 (Y2)); double BB2 = 200.0 * (transform2(Y2) - transform2 (Z2)); double dL = LL - LL2; double dA = AA - AA2; double dB = BB - BB2; return scm_from_double (sqrt (dL * dL + dA * dA + dB * dB)); }
void HomogeneousMatrixTest::testRPYConversions() { double xExpected, yExpected, zExpected, rollExpected, pitchExpected, yawExpected; double xActual, yActual, zActual, rollActual, pitchActual, yawActual; IHomogeneousMatrix44::IHomogeneousMatrix44Ptr transform1(new HomogeneousMatrix44()); xExpected = 1.0; yExpected = 2.0; zExpected = 3.0; rollExpected = 0.5*M_PI; pitchExpected = 0.0; yawExpected = 0.0; HomogeneousMatrix44::xyzRollPitchYawToMatrix(xExpected, yExpected, zExpected, rollExpected, pitchExpected, yawExpected, transform1); std::cout << "---> transform1 " << std::endl <<*transform1; HomogeneousMatrix44::matrixToXyzRollPitchYaw(transform1, xActual, yActual, zActual, rollActual, pitchActual, yawActual); CPPUNIT_ASSERT_DOUBLES_EQUAL(xExpected, xActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yExpected, yActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(zExpected, zActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(rollExpected, rollActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(pitchExpected, pitchActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yawExpected, yawActual, maxTolerance); xExpected = 1.0; yExpected = 2.0; zExpected = 3.0; rollExpected = 0.0; pitchExpected = 0.0; yawExpected = 0.5 * M_PI; Eigen::AngleAxis<double> rotation2(yawExpected, Eigen::Vector3d(0,0,1)); Transform3d transformation2; transformation2 = Eigen::Affine3d::Identity(); transformation2.translate(Eigen::Vector3d(xExpected,yExpected,zExpected)); transformation2.rotate(rotation2); IHomogeneousMatrix44::IHomogeneousMatrix44Ptr transform2(new HomogeneousMatrix44(&transformation2)); HomogeneousMatrix44::matrixToXyzRollPitchYaw(transform2, xActual, yActual, zActual, rollActual, pitchActual, yawActual); CPPUNIT_ASSERT_DOUBLES_EQUAL(xExpected, xActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yExpected, yActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(zExpected, zActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(rollExpected, rollActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(pitchExpected, pitchActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yawExpected, yawActual, maxTolerance); xExpected = 1.0; yExpected = 2.0; zExpected = 3.0; rollExpected = 0.0; pitchExpected = 0.5 * M_PI; yawExpected = 0; Eigen::AngleAxis<double> rotation3(pitchExpected, Eigen::Vector3d(0,1,0)); Transform3d transformation3; transformation3 = Eigen::Affine3d::Identity(); transformation3.translate(Eigen::Vector3d(xExpected,yExpected,zExpected)); transformation3.rotate(rotation3); IHomogeneousMatrix44::IHomogeneousMatrix44Ptr transform3(new HomogeneousMatrix44(&transformation3)); HomogeneousMatrix44::matrixToXyzRollPitchYaw(transform3, xActual, yActual, zActual, rollActual, pitchActual, yawActual); CPPUNIT_ASSERT_DOUBLES_EQUAL(xExpected, xActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yExpected, yActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(zExpected, zActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(rollExpected, rollActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(pitchExpected, pitchActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yawExpected, yawActual, maxTolerance); xExpected = 1.0; yExpected = 2.0; zExpected = 3.0; rollExpected = 0.5 * M_PI; pitchExpected = 0.0; yawExpected = 0; Eigen::AngleAxis<double> rotation4(rollExpected, Eigen::Vector3d(1,0,0)); Transform3d transformation4; transformation4 = Eigen::Affine3d::Identity(); transformation4.translate(Eigen::Vector3d(xExpected,yExpected,zExpected)); transformation4.rotate(rotation4); IHomogeneousMatrix44::IHomogeneousMatrix44Ptr transform4(new HomogeneousMatrix44(&transformation4)); HomogeneousMatrix44::matrixToXyzRollPitchYaw(transform4, xActual, yActual, zActual, rollActual, pitchActual, yawActual); std::cout << "---> transform4 " << std::endl <<*transform4; CPPUNIT_ASSERT_DOUBLES_EQUAL(xExpected, xActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yExpected, yActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(zExpected, zActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(rollExpected, rollActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(pitchExpected, pitchActual, maxTolerance); CPPUNIT_ASSERT_DOUBLES_EQUAL(yawExpected, yawActual, maxTolerance); /* CHecke if Eigen generated and xyzRPY generated _matices_ are similar */ const double* matrixData1 = transform1->getRawData(); const double* matrixData4 = transform4->getRawData(); for (unsigned int i = 0; i < 16; ++i) { CPPUNIT_ASSERT_DOUBLES_EQUAL(matrixData1[i], matrixData4[i], maxTolerance); } }
template <typename PointInT> void pcl::ConvexHull<PointInT>::performReconstruction (PointCloud &hull, std::vector<pcl::Vertices> &polygons, bool fill_polygon_data) { // FInd the principal directions EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; Eigen::Vector4f xyz_centroid; compute3DCentroid (*input_, *indices_, xyz_centroid); computeCovarianceMatrix (*input_, *indices_, xyz_centroid, covariance_matrix); EIGEN_ALIGN16 Eigen::Vector3f eigen_values; EIGEN_ALIGN16 Eigen::Matrix3f eigen_vectors; pcl::eigen33 (covariance_matrix, eigen_vectors, eigen_values); Eigen::Affine3f transform1; transform1.setIdentity (); int dim = 3; if (eigen_values[0] / eigen_values[2] < 1.0e-5) { // We have points laying on a plane, using 2d convex hull // Compute transformation bring eigen_vectors.col(i) to z-axis eigen_vectors.col (2) = eigen_vectors.col (0).cross (eigen_vectors.col (1)); eigen_vectors.col (1) = eigen_vectors.col (2).cross (eigen_vectors.col (0)); transform1 (0, 2) = eigen_vectors (0, 0); transform1 (1, 2) = eigen_vectors (1, 0); transform1 (2, 2) = eigen_vectors (2, 0); transform1 (0, 1) = eigen_vectors (0, 1); transform1 (1, 1) = eigen_vectors (1, 1); transform1 (2, 1) = eigen_vectors (2, 1); transform1 (0, 0) = eigen_vectors (0, 2); transform1 (1, 0) = eigen_vectors (1, 2); transform1 (2, 0) = eigen_vectors (2, 2); transform1 = transform1.inverse (); dim = 2; } else transform1.setIdentity (); PointCloud cloud_transformed; pcl::demeanPointCloud (*input_, *indices_, xyz_centroid, cloud_transformed); pcl::transformPointCloud (cloud_transformed, cloud_transformed, transform1); // True if qhull should free points in qh_freeqhull() or reallocation boolT ismalloc = True; // option flags for qhull, see qh_opt.htm char flags[] = "qhull Tc"; // output from qh_produce_output(), use NULL to skip qh_produce_output() FILE *outfile = NULL; // error messages from qhull code FILE *errfile = stderr; // 0 if no error from qhull int exitcode; // Array of coordinates for each point coordT *points = (coordT *)calloc (cloud_transformed.points.size () * dim, sizeof(coordT)); for (size_t i = 0; i < cloud_transformed.points.size (); ++i) { points[i * dim + 0] = (coordT)cloud_transformed.points[i].x; points[i * dim + 1] = (coordT)cloud_transformed.points[i].y; if (dim > 2) points[i * dim + 2] = (coordT)cloud_transformed.points[i].z; } // Compute convex hull exitcode = qh_new_qhull (dim, cloud_transformed.points.size (), points, ismalloc, flags, outfile, errfile); if (exitcode != 0) { PCL_ERROR ("[pcl::%s::performReconstrution] ERROR: qhull was unable to compute a convex hull for the given point cloud (%lu)!\n", getClassName ().c_str (), (unsigned long) input_->points.size ()); //check if it fails because of NaN values... if (!cloud_transformed.is_dense) { bool NaNvalues = false; for (size_t i = 0; i < cloud_transformed.size (); ++i) { if (!pcl_isfinite (cloud_transformed.points[i].x) || !pcl_isfinite (cloud_transformed.points[i].y) || !pcl_isfinite (cloud_transformed.points[i].z)) { NaNvalues = true; break; } } if (NaNvalues) PCL_ERROR ("[pcl::%s::performReconstruction] ERROR: point cloud contains NaN values, consider running pcl::PassThrough filter first to remove NaNs!\n", getClassName ().c_str ()); } hull.points.resize (0); hull.width = hull.height = 0; polygons.resize (0); qh_freeqhull (!qh_ALL); int curlong, totlong; qh_memfreeshort (&curlong, &totlong); return; } qh_triangulate (); int num_facets = qh num_facets; int num_vertices = qh num_vertices; hull.points.resize (num_vertices); vertexT * vertex; int i = 0; // Max vertex id int max_vertex_id = -1; FORALLvertices { if ((int)vertex->id > max_vertex_id) max_vertex_id = vertex->id; } ++max_vertex_id; std::vector<int> qhid_to_pcidx (max_vertex_id); FORALLvertices { // Add vertices to hull point_cloud hull.points[i].x = vertex->point[0]; hull.points[i].y = vertex->point[1]; if (dim>2) hull.points[i].z = vertex->point[2]; else hull.points[i].z = 0; qhid_to_pcidx[vertex->id] = i; // map the vertex id of qhull to the point cloud index ++i; } if (fill_polygon_data) { if (dim == 3) { polygons.resize (num_facets); int dd = 0; facetT * facet; FORALLfacets { polygons[dd].vertices.resize (3); // Needed by FOREACHvertex_i_ int vertex_n, vertex_i; FOREACHvertex_i_((*facet).vertices) //facet_vertices.vertices.push_back (qhid_to_pcidx[vertex->id]); polygons[dd].vertices[vertex_i] = qhid_to_pcidx[vertex->id]; ++dd; } } else {