QhullPoint QhullPoints:: value(int idx) const { QhullPoint p; if(idx>=0 && idx<count()){ p.defineAs(point_dimension, point_first+idx*point_dimension); } return p; }//value
ostream & operator<<(ostream &os, const QhullPointSet::PrintPointSet &pr) { const QhullPointSet s= *pr.point_set; if (pr.print_message) { os << pr.print_message; } for(QhullPointSet::const_iterator i=s.begin(); i != s.end(); ++i){ const QhullPoint point= *i; os << point.print(pr.run_id); } return os; }//printPointSet
//! Duplicate of printvertices [io.c] //! If pr.run_id==UsingLibQhull::NOqhRunId, no access to qh [needed for QhullPoint] ostream & operator<<(ostream &os, const QhullVertexSet::PrintVertexSet &pr){ os << pr.message; const QhullVertexSet *vs= pr.Vertex_set; QhullVertexSetIterator i= *vs; while(i.hasNext()){ const QhullVertex v= i.next(); const QhullPoint p= v.point(); os << " p" << p.id(pr.run_id) << "(v" << v.id() << ")"; } os << endl; return os; }//<< PrintVertexSet
void Point_test:: t_construct() { QhullPoint p; QCOMPARE(p.dimension(), 0); coordT c[]= {0.0, 1.0, 2.0}; QhullPoint p2; p2.defineAs(3, c); QCOMPARE(p2.dimension(), 3); QCOMPARE(p2.coordinates(), c); coordT c2[]= {0.0, 1.0, 2.0}; QhullPoint p3(3, c2); QVERIFY(p3==p2); QhullPoint p5(p3); QVERIFY(p5==p3); }//t_construct
ostream & operator<<(ostream &os, const QhullPointSet::PrintIdentifiers &pr) { os << pr.print_message; const QhullPointSet s= *pr.point_set; QhullPointSetIterator i(s); while(i.hasNext()){ if(i.hasPrevious()){ os << " "; } const QhullPoint point= i.next(); countT id= point.id(); os << "p" << id; } os << endl; return os; }//PrintIdentifiers
ostream & operator<<(ostream &os, const QhullPointSet::PrintIdentifiers &pr) { const QhullPointSet s= *pr.point_set; if (pr.print_message) { os << pr.print_message; } for(QhullPointSet::const_iterator i=s.begin(); i != s.end(); ++i){ if(i!=s.begin()){ os << " "; } const QhullPoint point= *i; int id= point.id(pr.run_id); os << "p" << id; } os << endl; return os; }//PrintIdentifiers
//! Return distance betweeen two points. double QhullPoint:: distance(const QhullPoint &p) const { const coordT *c= coordinates(); const coordT *c2= p.coordinates(); int dim= dimension(); QHULL_ASSERT(dim==p.dimension()); double dist; switch(dim){ case 2: dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]); break; case 3: dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]); break; case 4: dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]); break; case 5: dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]); break; case 6: dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]) + (c[5]-c2[5])*(c[5]-c2[5]); break; case 7: dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]) + (c[5]-c2[5])*(c[5]-c2[5]) + (c[6]-c2[6])*(c[6]-c2[6]); break; case 8: dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]) + (c[5]-c2[5])*(c[5]-c2[5]) + (c[6]-c2[6])*(c[6]-c2[6]) + (c[7]-c2[7])*(c[7]-c2[7]); break; default: dist= 0.0; for(int k=dim; k--; ){ dist += (*c - *c2) * (*c - *c2); ++c; ++c2; } break; } return sqrt(dist); }//distance
//! Return distance from point to hyperplane. //! If greater than zero, the point is above the facet (i.e., outside). // qh_distplane [geom.c], QhullFacet::distance, and QhullHyperplane::distance are copies // Does not support RANDOMdist or logging double QhullHyperplane:: distance(const QhullPoint &p) const { const coordT *point= p.coordinates(); int dim= p.dimension(); QHULL_ASSERT(dim==dimension()); const coordT *normal= coordinates(); double dist; switch (dim){ case 2: dist= offset() + point[0] * normal[0] + point[1] * normal[1]; break; case 3: dist= offset() + point[0] * normal[0] + point[1] * normal[1] + point[2] * normal[2]; break; case 4: dist= offset()+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]; break; case 5: dist= offset()+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]; break; case 6: dist= offset()+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5]; break; case 7: dist= offset()+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5]+point[6]*normal[6]; break; case 8: dist= offset()+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5]+point[6]*normal[6]+point[7]*normal[7]; break; default: dist= offset(); for (int k=dim; k--; ) dist += *point++ * *normal++; break; } return dist; }//distance
void PointCoordinates:: append(const QhullPoint &p) { setDimension(p.dimension()); append(p.dimension(), p.coordinates()); }//append QhullPoint