bool TrainExample::isEqual(const ParseTree & pt) const { assert(pts().size() >= 2); const ParseInfo * p = pts()[0].rootNode()->parseInfo(&pts()[0]); const ParseInfo * p1 = pt.rootNode()->parseInfo(&pt); assert(p); assert(p1); return (pts()[0].dataId() == pt.dataId()) && (p->c_ == p1->c_) && (p->l_ == p1->l_) && (p->x_ == p1->x_) && (p->y_ == p1->y_ ); }
XC::MidDistanceBeamIntegration::MidDistanceBeamIntegration(int nIP,const Vector &pt) : ParameterIDBeamIntegration(BEAM_INTEGRATION_TAG_MidDistance,pt) { for(int i = 0; i < nIP; i++) { int key = i; for(int j = i+1; j < nIP; j++) { if(pts(j) < pts(key)) { key = j; std::cerr << "MidDistanceBeamIntegration::MidDistanceBeamIntegration -- point are not sorted; sort before calling constructor" << std::endl; } } //double temp = pts(i); //pts(i) = pts(key); //pts(key) = temp; } Vector mids(nIP-1); for(int i = 0; i < nIP-1; i++) { mids(i) = 0.5*(pts(i)+pts(i+1)); } wts(0) = mids(0); wts(nIP-1) = 1.0-mids(nIP-2); for(int i = 1; i < nIP-1; i++) { wts(i) = mids(i)-mids(i-1); } }
int Dmc_method::allocateIntermediateVariables(System * sys, Wavefunction_data * wfdata) { if(wf) delete wf; wf=NULL; if(sample) delete sample; sample=NULL; nelectrons=sys->nelectrons(0)+sys->nelectrons(1); wfdata->generateWavefunction(wf); sys->generateSample(sample); sample->attachObserver(wf); nwf=wf->nfunc(); if(wf->nfunc() >1) error("DMC doesn't support more than one guiding wave function"); guidingwf=new Primary; pts.Resize(nconfig); for(int i=0; i < nconfig; i++) { pts(i).age.Resize(nelectrons); pts(i).age=0; } average_var.Resize(avg_words.size()); average_var=NULL; for(int i=0; i< average_var.GetDim(0); i++) { allocate(avg_words[i], sys, wfdata, average_var(i)); } return 1; }
/* * returns a roboop spline given the joint space via points and total duration */ Spl_path* TrajectoryController::createSpline(vector<ColumnVector>& jsPoints, double duration) { int size = jsPoints.size(); if (size < 5) { return NULL; } //One row for time + 6 for each joint //TODO: ?? + 2 for adding the start and stop positions extra to keep the spline smooth Matrix pts(7, size); for (int i = 0; i < size; i++) { double time = 0.999 * (duration * i) / (size - 1); ColumnVector p = jsPoints.at(i); int index = i + 1; pts(1, index) = time; pts.SubMatrix(2, 7, index, index) = p; } cout << pts << endl; Spl_path* sp = new Spl_path(pts); return sp; }
std::unique_ptr<SceneGraph::Node> AddChain::synchronize( std::unique_ptr<SceneGraph::Node> n) { if (pts().size() == 0) { return nullptr; } if (m_state & DirtyState::Points) { n = std::make_unique<Node>(pts()); m_state ^= DirtyState::Points; } Node* node = static_cast<Node*>(n.get()); if (m_state & DirtyState::MousePos) { node->setLastPoint(m_mousePos); m_state ^= DirtyState::MousePos; } if (m_state & DirtyState::Finished) { n = nullptr; m_pts.clear(); m_state ^= DirtyState::Finished; } return n; }
void SkIntersectionHelper::dump() const { SkDPoint::Dump(pts()[0]); SkDPoint::Dump(pts()[1]); if (verb() >= SkPath::kQuad_Verb) { SkDPoint::Dump(pts()[2]); } if (verb() >= SkPath::kCubic_Verb) { SkDPoint::Dump(pts()[3]); } }
void hex_5elem_inline() { libMesh::Point origin = libMesh::Point(0,0.5,0.5); // end points std::vector<libMesh::Point> pts(5); pts[0] = libMesh::Point(5.0,0.5,0.5); // right pts[1] = libMesh::Point(3.75,0.0,0.25); // front pts[2] = libMesh::Point(1.25,0.77,1.0); // top pts[3] = libMesh::Point(2.22,1.0,0.667); // back pts[4] = libMesh::Point(0.38,0.57,0.0); // bottom // exit_elem IDs std::vector<unsigned int> exit_ids(5); exit_ids[0] = 4; exit_ids[1] = 3; exit_ids[2] = 1; exit_ids[3] = 2; exit_ids[4] = 0; std::string hex8_string = this->mesh_3D("HEX8",5.0,1.0,1.0,5,1,1); std::string hex27_string = this->mesh_3D("HEX27",5.0,1.0,1.0,5,1,1); this->run_test_with_mesh_from_file(origin,pts,exit_ids,hex8_string); this->run_test_with_mesh_from_file(origin,pts,exit_ids,hex27_string); }
void MapCarObject::DrawObject(const QRect & rBox, QPainter * pDC, MapObjectState eState) const { short iHeading; float cos0, sin0; QPoint ptCenter; QPointArray pts(3); if (m_pCar == NULL) return; m_pCar->m_mutexUpdate.lock(); iHeading = m_pCar->GetCurrentDirection(); m_pCar->m_mutexUpdate.unlock(); ptCenter = rBox.center(); cos0 = cosf(iHeading * RADIANSPERCENTIDEGREE); sin0 = sinf(iHeading * RADIANSPERCENTIDEGREE); pts[0] = ptCenter + QPoint((int)round(MAPCAROBJECT_CIRCLE_RADIUS*sin0), (int)round(-MAPCAROBJECT_CIRCLE_RADIUS*cos0)); pts[1] = ptCenter + QPoint((int)round((MAPCAROBJECT_ARROW_WIDTH/2)*cos0-(MAPCAROBJECT_ARROW_LENGTH-MAPCAROBJECT_CIRCLE_RADIUS)*sin0), (int)round((MAPCAROBJECT_ARROW_LENGTH-MAPCAROBJECT_CIRCLE_RADIUS)*cos0+(MAPCAROBJECT_ARROW_WIDTH/2)*sin0)); pts[2] = ptCenter + QPoint((int)round(-(MAPCAROBJECT_ARROW_WIDTH/2)*cos0-(MAPCAROBJECT_ARROW_LENGTH-MAPCAROBJECT_CIRCLE_RADIUS)*sin0), (int)round((MAPCAROBJECT_ARROW_LENGTH-MAPCAROBJECT_CIRCLE_RADIUS)*cos0-(MAPCAROBJECT_ARROW_WIDTH/2)*sin0)); pDC->setPen(QPen(m_clrDraw, eState & MapObjectStateCurrent ? 2 : 0)); pDC->drawLine(pts[0], pts[1]); pDC->drawLine(pts[0], pts[2]); if (!(eState & MapObjectStateInactive)) pDC->drawEllipse((int)round(ptCenter.x() - MAPCAROBJECT_CIRCLE_RADIUS), (int)round(ptCenter.y() - MAPCAROBJECT_CIRCLE_RADIUS), (int)round(2*MAPCAROBJECT_CIRCLE_RADIUS), (int)round(2*MAPCAROBJECT_CIRCLE_RADIUS)); if (hasReceivedCurrentMsg()) { QBrush brushOld = pDC->brush(); pDC->setBrush(m_clrDraw); pDC->drawPolygon(pts); pDC->setBrush(brushOld); } }
void ArrowLine::drawShape(QPainter &p) { p.setPen(darkGray); QCanvasLine::drawShape(p); double angle = computeAngle(startPoint().x(), startPoint().y(), endPoint().x(), endPoint().y()); QPointArray pts(3); QWMatrix m; int x, y; m.rotate(angle); m.map(-5, -2, &x, &y); pts.setPoint(0, x, y); m.map(-5, 2, &x, &y); pts.setPoint(1, x, y); m.map(0, 0, &x, &y); pts.setPoint(2, x, y); pts.translate(endPoint().x(), endPoint().y()); p.setBrush(QColor(darkGray)); p.drawPolygon(pts); }
void PolyMolecule::createPolyData(vtkPolyData *poly_data) { int N = m_Nodes.size(); EG_VTKSP(vtkPoints, points); points->SetNumberOfPoints(N); for (int i = 0; i < N; ++i) { vec3_t x = getXNode(i); points->SetPoint(i, x.data()); } poly_data->Allocate(m_Faces.size()); poly_data->SetPoints(points); for (int i = 0; i < m_Faces.size(); ++i) { QVector<vtkIdType> pts(m_Faces[i].size()); for (int j = 0; j < m_Faces[i].size(); ++j) { pts[j] = m_Faces[i][j]; } if (pts.size() == 3) { poly_data->InsertNextCell(VTK_TRIANGLE, pts.size(), pts.data()); } else if (pts.size() == 4) { poly_data->InsertNextCell(VTK_QUAD, pts.size(), pts.data()); } else { poly_data->InsertNextCell(VTK_POLYGON, pts.size(), pts.data()); } } }
/** * @function fit_BB * @brief */ void fit_BB( std::vector<pcl::PointCloud<pcl::PointXYZRGBA>::Ptr > _clusters ) { double dim[3]; Eigen::Isometry3d Tf; for( int i = 0; i < _clusters.size(); ++i ) { printf("\t * Fitting box for cluster %d \n", i ); pcl::PointCloud<pcl::PointXYZ>::Ptr p( new pcl::PointCloud<pcl::PointXYZ>() ); p->points.resize( _clusters[i]->points.size() ); for(int j = 0; j < _clusters[i]->points.size(); ++j ) { p->points[j].x = _clusters[i]->points[j].x; p->points[j].y = _clusters[i]->points[j].y; p->points[j].z = _clusters[i]->points[j].z; } p->width = 1; p->height = p->points.size(); // Get Bounding Box pointcloudToBB( p, dim, Tf ); // Store (cube) pcl::PointCloud<pcl::PointXYZ>::Ptr pts( new pcl::PointCloud<pcl::PointXYZ>() ); pcl::PointCloud<pcl::PointXYZ>::Ptr final( new pcl::PointCloud<pcl::PointXYZ>() ); pts = sampleSQ_uniform( dim[0]/2, dim[1]/2, dim[2]/2, 0.1, 0.1 ); pcl::transformPointCloud( *pts, *final, Tf.matrix() ); char name[50]; sprintf( name, "bb_%d.pcd", i); pcl::io::savePCDFileASCII(name, *final ); } }
void hex_27elem_3x3x3() { libMesh::Point origin = libMesh::Point(0.0,1.5,1.5); // end points std::vector<libMesh::Point> pts(5); pts[0] = libMesh::Point(3.0,1.5,1.5); // right pts[1] = libMesh::Point(1.875,0.0,2.584); // front pts[2] = libMesh::Point(1.1,2.67,3.0); // top pts[3] = libMesh::Point(2.75,3.0,0.25); // back pts[4] = libMesh::Point(2.23,2.59,0.0); // bottom // exit_elem IDs std::vector<unsigned int> exit_ids(5); exit_ids[0] = 14; exit_ids[1] = 19; exit_ids[2] = 25; exit_ids[3] = 8; exit_ids[4] = 8; std::string hex8_string = this->mesh_3D("HEX8",3.0,3.0,3.0,3,3,3); std::string hex27_string = this->mesh_3D("HEX27",3.0,3.0,3.0,3,3,3); this->run_test_with_mesh_from_file(origin,pts,exit_ids,hex8_string); this->run_test_with_mesh_from_file(origin,pts,exit_ids,hex27_string); }
TEST(kdtree, DefaultConstructor) { typedef double realScalarType; typedef point<realScalarType> pointType; typedef kdTree<pointType> kdTreeType; std::default_random_engine generator; std::normal_distribution<double> distribution(0.,1.0); const size_t numDims = 1; const size_t numPoints = 10; std::vector<pointType> pts(numPoints); for(size_t i=0;i<numPoints;++i) { std::vector<double> pv(numDims); for(size_t j=0;j<numDims;++j) { pv[j] = distribution(generator); } pointType pt(pv); pts[i] = pt; } kdTreeType kdtr(pts); }
void NurbsCurveSP<T,N>::modOnlySurfCPby(int i, const HPoint_nD<T,N>& a) { Vector<T> u(2*deg_+3) ; Vector< Point_nD<T,N> > pts(2*deg_+3) ; int n=0; for(int j=i-deg_-1; j<=i+deg_+1; ++j) { if(j<0) continue ; if(j>=P.n()) break ; u[n] = maxAt_[j] ; if( j == i) { pts[n].x() = a.x() ; pts[n].y() = a.y() ; pts[n].z() = a.z() ; } //else // pts[n] = Point3D(0,0,0) ; pts is alredy set to 0,0,0 ++n ; } u.resize(n) ; pts.resize(n) ; movePoint(u,pts) ; }
visualization_msgs::MarkerArray OccupancyGrid::getVisualization(std::string type) { visualization_msgs::MarkerArray ma; if(type.compare("bounds") == 0) { double dimx, dimy, dimz, originx, originy, originz; std::vector<geometry_msgs::Point> pts(10); getOrigin(originx, originy, originz); getWorldSize(dimx,dimy,dimz); pts[0].x = originx; pts[0].y = originy; pts[0].z = originz; pts[1].x = originx+dimx; pts[1].y = originy; pts[1].z = originz; pts[2].x = originx+dimx; pts[2].y = originy+dimy; pts[2].z = originz; pts[3].x = originx; pts[3].y = originy+dimy; pts[3].z = originz; pts[4].x = originx; pts[4].y = originy; pts[4].z = originz; pts[5].x = originx; pts[5].y = originy; pts[5].z = originz+dimz; pts[6].x = originx+dimx; pts[6].y = originy; pts[6].z = originz+dimz; pts[7].x = originx+dimx; pts[7].y = originy+dimy; pts[7].z = originz+dimz; pts[8].x = originx; pts[8].y = originy+dimy; pts[8].z = originz+dimz; pts[9].x = originx; pts[9].y = originy; pts[9].z = originz+dimz; ma.markers.resize(1); ma.markers[0] = viz::getLineMarker(pts, 0.05, 10, getReferenceFrame(), "collision_space_bounds", 0); } else if(type.compare("distance_field") == 0) { visualization_msgs::Marker m; // grid_->getIsoSurfaceMarkers(0.01, 0.03, getReferenceFrame(), ros::Time::now(), Eigen::Affine3d::Identity(), m); //grid_->getIsoSurfaceMarkers(0.01, 0.08, getReferenceFrame(), ros::Time::now(), tf::Transform(tf::createIdentityQuaternion(), tf::Vector3(0,0,0)), m); grid_->getIsoSurfaceMarkers(0.01, 0.02, getReferenceFrame(), ros::Time::now(), m); m.color.a +=0.2; ma.markers.push_back(m); } else if(type.compare("occupied_voxels") == 0) { visualization_msgs::Marker marker; std::vector<geometry_msgs::Point> voxels; getOccupiedVoxels(voxels); marker.header.seq = 0; marker.header.stamp = ros::Time::now(); marker.header.frame_id = getReferenceFrame(); marker.ns = "occupied_voxels"; marker.id = 1; marker.type = visualization_msgs::Marker::POINTS; marker.action = visualization_msgs::Marker::ADD; marker.lifetime = ros::Duration(0.0); marker.scale.x = grid_->getResolution() / 2.0; marker.scale.y = grid_->getResolution() / 2.0; marker.scale.z = grid_->getResolution() / 2.0; marker.color.r = 0.8; marker.color.g = 0.3; marker.color.b = 0.5; marker.color.a = 1; marker.points = voxels; ma.markers.push_back(marker); } else ROS_ERROR("No visualization found of type '%s'.", type.c_str()); return ma; }
void QChain::cutCircle(Circle circle) { if (m_vertices.size() == 0) return; circle.setCenter(circle.pos()); QPainterPath cr; cr.addEllipse(circle.x - circle.r, circle.y - circle.r, 2 * circle.r, 2 * circle.r); QPolygonF polygon; for (QPointF p : m_vertices) polygon.append(p); QPainterPath chain; chain.addPolygon(polygon); if (!chain.intersects(cr)) return; chain = chain.subtracted(cr); for (const QPolygonF &poly : chain.toSubpathPolygons()) { std::vector<Vector2d> pts(poly.begin(), poly.end() - 1); if (std::fabs(Geometry::area(pts.begin(), pts.end())) > 5.f) { auto chain = std::make_unique<QChain>(world()); chain->setVertices(std::vector<QPointF>(pts.begin(), pts.end())); chain->initializeLater(world()); world()->itemSet()->addBody(std::move(chain)); } } m_vertices.clear(); destroyLater(); }
void Widget::showGnuplot(){ Gnuplot gp; std::cout << "Press Ctrl-C to quit (closing gnuplot window doesn't quit)." << std::endl; gp << "set yrange [-1:1]\n"; const int N = 1000; std::vector<double> pts(N); double theta = 0; while(1) { for(int i=0; i<N; i++) { double alpha = (double(i)/N-0.5) * 10; pts[i] = sin(alpha*8.0 + theta) * exp(-alpha*alpha/2.0); } gp << "plot '-' binary" << gp.binFmt1d(pts, "array") << "with lines notitle\n"; gp.sendBinary1d(pts); gp.flush(); theta += 0.2; myMath::mysleep(100); } }
unsigned int RemoveDuplicate::removeDuplicateTriangles(std::vector<unsigned int>& tris) { int numT = (int)tris.size(); std::map<Triangle, int, bool(*)(const Triangle&, const Triangle&)> pts(Triangleless); std::vector<unsigned int> trisNew; trisNew.reserve(numT); int cnt = 0; for(int i1 = 0; i1 < numT/3; i1++) { Triangle tri; tri.Idx0 = tris[3*i1+0]; tri.Idx1 = tris[3*i1+1]; tri.Idx2 = tris[3*i1+2]; std::map<Triangle, int, bool(*)(const Triangle&, const Triangle&)>::iterator it = pts.find(tri); if(it == pts.end()) { pts.insert(std::make_pair(tri, cnt)); trisNew.push_back(tri.Idx0); trisNew.push_back(tri.Idx1); trisNew.push_back(tri.Idx2); cnt++; } } tris = std::vector<unsigned int>(trisNew.begin(), trisNew.end()); std::cerr << "Removed " << numT/3-cnt << " duplicate triangles of " << numT/3 << " triangles" << std::endl; return cnt; }
//=========================================================================== void Eval1D3DSurf::eval(double u, double v, int n, Point der[]) const //=========================================================================== { if (n == 0) { der[0] = eval(u, v); return; } vector<Point> pts((n+1)*(n+2)/2); sf_->point(pts, u, v, n); if (sf_->dimension() == 1) { der[0] = Point(u, v, pts[0][0]); if (n >= 1) { der[1] = Point(1, 0, pts[1][0]); der[2] = Point(0, 1, pts[2][0]); for (size_t ki=3; ki<pts.size(); ++ki) der[ki] = Point(0, 0, pts[ki][0]); } } else { for (size_t ki=0; ki<pts.size(); ++ki) der[ki] = pts[ki]; } }
/*private static*/ TaggedLineString::CoordVectPtr TaggedLineString::extractCoordinates( const std::vector<TaggedLineSegment*>& segs) { CoordVectPtr pts(new CoordVect()); #if GEOS_DEBUG cerr << __FUNCTION__ << " segs.size: " << segs.size() << endl; #endif std::size_t i=0, size=segs.size(); assert(size); for (; i<size; i++) { TaggedLineSegment* seg = segs[i]; assert(seg); pts->push_back(seg->p0); } // add last point pts->push_back(segs[size-1]->p1); return pts; }
/*! * Reads the point list associated with this BCDataSet_t * \param ptlist point list [Output] */ void BCDataSet_t::readPointList( vector<int>& ptlist ) const { if ( parent().isA( "BC_t" ) ) { go_here(); PointSetType_t psettype; int npts; int ier = cg_ptset_info( &psettype, &npts ); check_error( "BCDataSet_t::readPoinRange", "cg_ptset_info", ier ); if ( psettype != PointList ) throw cgns_mismatch( "BCDataSet_t::readPoinRange", "This BCDataSet_t is not defined with a PointList" ); Array<int> pts(npts); ier = cg_ptset_read( pts ); check_found( "BCDataSet_t::readPoinRange", "IndexRange_t", ier ); check_error( "BCDataSet_t::readPoinRange", "cg_ptset_read", ier ); ptlist = pts; } else if ( parent().isA( "FamilyBC_t" ) ) { /* TODO */ } throw std::logic_error( "BCDataSet_t::readBCData - immediate parent is not a BC_t nor a FamilyBC_t ??? !!!" ); }
/* compares evaluations on corner cases */ void eval_spline3d_onbrks() { Spline3d spline = spline3d(); RowVectorXd u = spline.knots(); MatrixXd pts(11,3); pts << 0.959743958516081, 0.340385726666133, 0.585267750979777, 0.959743958516081, 0.340385726666133, 0.585267750979777, 0.959743958516081, 0.340385726666133, 0.585267750979777, 0.430282980289940, 0.713074680056118, 0.720373307943349, 0.558074875553060, 0.681617921034459, 0.804417124839942, 0.407076008291750, 0.349707710518163, 0.617275937419545, 0.240037008286602, 0.738739390398014, 0.324554153129411, 0.302434111480572, 0.781162443963899, 0.240177089094644, 0.251083857976031, 0.616044676146639, 0.473288848902729, 0.251083857976031, 0.616044676146639, 0.473288848902729, 0.251083857976031, 0.616044676146639, 0.473288848902729; pts.transposeInPlace(); for (int i=0; i<u.size(); ++i) { Vector3d pt = spline(u(i)); VERIFY( (pt - pts.col(i)).norm() < 1e-14 ); } }
/* compares evaluations against known results */ void eval_spline3d() { Spline3d spline = spline3d(); RowVectorXd u(10); u << 0.351659507062997, 0.830828627896291, 0.585264091152724, 0.549723608291140, 0.917193663829810, 0.285839018820374, 0.757200229110721, 0.753729094278495, 0.380445846975357, 0.567821640725221; MatrixXd pts(10,3); pts << 0.707620811535916, 0.510258911240815, 0.417485437023409, 0.603422256426978, 0.529498282727551, 0.270351549348981, 0.228364197569334, 0.423745615677815, 0.637687289287490, 0.275556796335168, 0.350856706427970, 0.684295784598905, 0.514519311047655, 0.525077224890754, 0.351628308305896, 0.724152914315666, 0.574461155457304, 0.469860285484058, 0.529365063753288, 0.613328702656816, 0.237837040141739, 0.522469395136878, 0.619099658652895, 0.237139665242069, 0.677357023849552, 0.480655768435853, 0.422227610314397, 0.247046593173758, 0.380604672404750, 0.670065791405019; pts.transposeInPlace(); for (int i=0; i<u.size(); ++i) { Vector3d pt = spline(u(i)); VERIFY( (pt - pts.col(i)).norm() < 1e-14 ); } }
void NurbsSurfaceSP<T,N>::modOnlySurfCPby(int i, int j, const HPoint_nD<T,N>& a){ int sizeU, sizeV ; sizeU = 2*this->degU+3 ; if(i-this->degU-1<0) sizeU += i-this->degU-1 ; if(i+this->degU+1>=this->P.rows()) sizeU -= i+this->degU+1-this->P.rows() ; sizeV = 2*this->degV+3 ; if(j-this->degV-1<0) sizeV += j-this->degV-1 ; if(j+this->degV+1>=this->P.cols()) sizeV -= j+this->degV+1-this->P.cols() ; Vector<T> u(sizeU) ; Vector<T> v(sizeV) ; Vector<Point_nD<T,N> > pts(sizeU*sizeV) ; Vector<int> pu(sizeU*sizeV) ; Vector<int> pv(sizeU*sizeV) ; int n=0; int nu = 0 ; int nv = 0 ; for(int k=i-this->degU-1;k<=i+this->degU+1;++k){ if(k<0) continue ; if(k>=this->P.rows()) break ; nv = 0 ; for(int l=j-this->degV-1;l<=j+this->degV+1;++l){ if(l<0) continue ; if(l>=this->P.cols()) break ; if( k == i && j==l){ pts[n].x() = a.x() ; pts[n].y() = a.y() ; pts[n].z() = a.z() ; } //else //pts[n] = Point3D(0,0,0) ; pu[n] = nu ; pv[n] = nv ; if(k==i){ v[nv] = maxAtV_[l] ; // only need to initialise this once } ++n ; ++nv ; } u[nu] = maxAtU_[k] ; ++nu ; } u.resize(nu) ; v.resize(nv) ; pts.resize(n) ; pu.resize(n) ; pv.resize(n) ; movePoint(u,v,pts,pu,pv) ; }
vector<Point2f> rotatePointsByRotationMatrix(const vector<Point2f>& original,const Mat& RM) { vector<Point2f> pts(original); for (int i = 0 ; i < pts.size() ; i ++) { pts[i] = rotatePointByRotationMatrix(pts[i], RM); } return pts; }
//===== Interpolate Creates cubic spline with either not-a-knot ends or closed ends ====// void VspCurve::InterpolateCSpline( vector< vec3d > & input_pnt_vec, const vector<double> ¶m, bool closed_flag ) { // do some checking of vector lengths if ( closed_flag ) { if ( param.size() != ( input_pnt_vec.size() + 1 ) ) { std::cerr << "Invalid number of points and parameters in curve interpolation " << __LINE__ << std::endl; assert( false ); return; } } else { if ( param.size() != input_pnt_vec.size() ) { std::cerr << "Invalid number of points and parameters in curve interpolation " << __LINE__ << std::endl; assert( false ); return; } } // copy points over to new type vector<curve_point_type> pts( input_pnt_vec.size() ); for ( size_t i = 0; i < pts.size(); ++i ) { pts[i] << input_pnt_vec[i].x(), input_pnt_vec[i].y(), input_pnt_vec[i].z(); } // create creator for known number of segments int nseg( pts.size() - 1 ); if ( closed_flag ) { ++nseg; } piecewise_cubic_spline_creator_type pcsc( nseg ); // set the delta t for each curve segment pcsc.set_t0( param[0] ); for ( size_t i = 0; i < ( param.size() - 1 ); ++i ) { pcsc.set_segment_dt( param[i + 1] - param[i], i ); } if ( closed_flag ) { pcsc.set_closed_cubic_spline( pts.begin() ); } else { pcsc.set_cubic_spline( pts.begin() ); } if ( !pcsc.create( m_Curve ) ) { std::cerr << "Failed to create CSpline. " << __LINE__ << std::endl; } }
void Dmc_method::savecheckpoint(string & filename, Sample_point * config) { if(save_trace!="") { if(mpi_info.node==0) { cout << "entering trace write" << endl; long int time_ent=clock(); FILE * f=fopen(save_trace.c_str(),"a"); for(int i=0;i<nconfig; i++) { pts(i).config_pos.writeBinary(f,pts(i).weight); // fwrite(&pts(i).weight, sizeof(doublevar),1, f); } #ifdef USE_MPI Dmc_point tmppt; for(int p=1; p < mpi_info.nprocs; p++) { int nconfigthis; MPI_Recv(nconfigthis,p); for(int i=0; i < nconfigthis; i++) { tmppt.config_pos.mpiReceive(p); MPI_Recv(tmppt.weight,p); tmppt.config_pos.writeBinary(f,tmppt.weight); } } #endif long int time_b=clock(); single_write(cout,"writing to trace : ",double(time_b-time_ent)/CLOCKS_PER_SEC,"\n"); fclose(f); } #ifdef USE_MPI else { MPI_Send(nconfig,0); for(int i=0; i< nconfig; i++) { pts(i).config_pos.mpiSend(0); MPI_Send(pts(i).weight,0); } } #endif } if(filename=="") return; write_configurations(filename, pts); return; }
void UpdateDesiredMeshDensity::computeFeature(const QList<point_t> points, QVector<double> &cl_pre, double res, int restriction_type) { int N = 0; QVector<vec3_t> pts(points.size()); for (int i = 0; i < points.size(); ++i) { pts[i] = points[i].x; } PointFinder pfind; pfind.setMaxNumPoints(5000); pfind.setPoints(pts); for (int i = 0; i < points.size(); ++i) { double h = -1; foreach (int i_points, points[i].idx) { h = max(h, cl_pre[i_points]); } if (h < 0) { h = 1e99; } QVector<int> close_points; pfind.getClosePoints(points[i].x, close_points, res*points[i].L); foreach (int j, close_points) { if (i != j) { ++N; vec3_t x1 = points[i].x; vec3_t x2 = points[j].x; vec3_t n1 = points[i].n; vec3_t n2 = points[j].n; vec3_t v = x2 - x1; if (n1*n2 < 0) { if (n1*v > 0) { if (fabs(GeometryTools::angle(n1, (-1)*n2)) <= m_FeatureThresholdAngle) { double l = v.abs()/fabs(n1*n2); if (l/res < h) { // check topological distance int search_dist = int(ceil(res)); bool topo_dist_ok = true; foreach (int k, points[i].idx) { vtkIdType id_node1 = m_Part.globalNode(k); foreach (int l, points[j].idx) { vtkIdType id_node2 = m_Part.globalNode(l); if (m_Part.computeTopoDistance(id_node1, id_node2, search_dist, restriction_type) < search_dist) { topo_dist_ok = false; break; } if (!topo_dist_ok) { break; } } } if (topo_dist_ok) { h = l/res; } } } } } }
void rspfAnnotationLineObject::computeBoundingRect() { vector<rspfDpt> pts(2); pts[0] = theStart; pts[1] = theEnd; theBoundingRect = rspfDrect(pts); }
void XC::MidDistanceBeamIntegration::getSectionLocations(int numSections, double L, double *xi) { const int nIP = pts.Size(); int i; for(i = 0; i < nIP; i++) xi[i] = pts(i); for( ; i < numSections; i++) xi[i] = 0.0; }