Bool_t RooHistN::hasIdenticalBinning(const RooHistN& other) const { // First check if number of bins is the same if (GetN() != other.GetN()) { return kFALSE ; } // Next require that all bin centers are the same Int_t i ; for (i=0 ; i<GetN() ; i++) { Double_t x1,x2,y1,y2 ; #if ROOT_VERSION_CODE >= ROOT_VERSION(4,0,1) GetPoint(i,x1,y1) ; other.GetPoint(i,x2,y2) ; #else const_cast<RooHistN&>(*this).GetPoint(i,x1,y1) ; const_cast<RooHistN&>(other).GetPoint(i,x2,y2) ; #endif if (fabs(x1-x2)>1e-10) { return kFALSE ; } } return kTRUE ; }
//某一特定顶点在三角形之内 Bool HawkRect2D::IsPointInside(const HawkVector2D& oVec) const { HawkTriangle2D oTrig1(Point,Edge[0],Edge[1]); HawkTriangle2D oTrig2(GetPoint(2),-Edge[0],-Edge[1]); return oTrig1.IsPointInside(oVec) || oTrig2.IsPointInside(oVec); }
IplImage* ShiftMapHierarchy::GetRetargetImageH() { IplImage* output = cvCreateImage(_outputSize, _input->depth, _input->nChannels); int num_pixels = _outputSize.width * _outputSize.height; printf("Rendering graph-cut result to image... \n"); for(int i = 0; i < num_pixels; i++) { int label = _gc->whatLabel(i); CvPoint point = GetPoint(i, _outputSize); CvPoint pointLabel = GetMappedPointInitialGuess(i, label, _outputSize, _shiftSize, _initialGuess); if(!IsOutside(pointLabel, _inputSize)) { CvScalar value = cvGet2D(_input, pointLabel.y, pointLabel.x); cvSet2D(output, point.y, point.x, value); } else { printf("warning mapped outside"); cvSet2D(output, point.y, point.x, cvScalar(255, 0, 0)); } } return output; }
float3 Ray::ClosestPoint(const float3 &targetPoint, float *d) const { float u = Max(0.f, Dot(targetPoint - pos, dir)); if (d) *d = u; return GetPoint(u); }
void CIni::SerGetPoint( BOOL bGet,CPoint & pt, CString strEntry, LPCSTR strSection, CPoint ptDefault) { if (bGet) pt = GetPoint(strEntry,ptDefault,strSection); else WritePoint(strEntry,pt, strSection); }
void HeightmapNode::SetValueToMap(int16 x, int16 y, float32 height, const AABBox3 &box) { int32 index = x + y * heightmap->Size(); hmap[index] = height; debugVertices[index].position = GetPoint(x, y, height, box); }
void CChartCandlestickSerie::DrawAll(CDC *pDC) { if (!m_bIsVisible) return; unsigned uFirst=0, uLast=0; if (!GetVisiblePoints(uFirst,uLast)) return; if (pDC->GetSafeHdc()) { ShadowBrush.CreateSolidBrush(m_ShadowColor); NewPen.CreatePen(PS_SOLID,1,m_SerieColor); ShadowPen.CreatePen(PS_SOLID,1,m_ShadowColor); BrushFill.CreateSolidBrush(m_SerieColor); BrushEmpty.CreateSolidBrush(RGB(255,255,255)); pDC->SetBkMode(TRANSPARENT); //To have lines limited in the drawing rectangle : pDC->IntersectClipRect(m_PlottingRect); for (m_uLastDrawnPoint=uFirst;m_uLastDrawnPoint<=uLast;m_uLastDrawnPoint++) { SChartCandlestickPoint Point = GetPoint(m_uLastDrawnPoint); DrawCandleStick(pDC, Point); } pDC->SelectClipRgn(NULL); BrushFill.DeleteObject(); BrushEmpty.DeleteObject(); NewPen.DeleteObject(); ShadowBrush.DeleteObject(); ShadowPen.DeleteObject(); } }
void Shape::Update() { // Get the total number of points of the shape unsigned int count = GetPointCount(); if (count < 3) { myVertices.Resize(0); myOutlineVertices.Resize(0); return; } myVertices.Resize(count + 2); // + 2 for center and repeated first point // Position for (unsigned int i = 0; i < count; ++i) myVertices[i + 1].Position = GetPoint(i); myVertices[count + 1].Position = myVertices[1].Position; // Update the bounding rectangle myVertices[0] = myVertices[1]; // so that the result of GetBounds() is correct myInsideBounds = myVertices.GetBounds(); // Compute the center and make it the first vertex myVertices[0].Position.x = myInsideBounds.Left + myInsideBounds.Width / 2; myVertices[0].Position.y = myInsideBounds.Top + myInsideBounds.Height / 2; // Color UpdateFillColors(); // Texture coordinates UpdateTexCoords(); // Outline UpdateOutline(); }
void SplineSeg3<D> :: GetCoeff (Vector & u) const { double t; int i; Point<D> p; DenseMatrix a(6, 6); DenseMatrix ata(6, 6); Vector f(6); u.SetSize(6); // ata.SetSymmetric(1); t = 0; for (i = 1; i <= 5; i++, t += 0.25) { p = GetPoint (t); a.Elem(i, 1) = p(0) * p(0); a.Elem(i, 2) = p(1) * p(1); a.Elem(i, 3) = p(0) * p(1); a.Elem(i, 4) = p(0); a.Elem(i, 5) = p(1); a.Elem(i, 6) = 1; } a.Elem(6, 1) = 1; CalcAtA (a, ata); u = 0; u.Elem(6) = 1; a.MultTrans (u, f); ata.Solve (f, u); }
void SplineSeg<D> :: GetPoints (int n, ARRAY<Point<D> > & points) { points.SetSize (n); if (n >= 2) for (int i = 0; i < n; i++) points[i] = GetPoint(double(i) / (n-1)); }
Bounds Bounds::GetTransformedBounds(const Matrix &m) const { Bounds newBounds; BOOL bInitialized=0; for(int i=0; i<8; i++) { Vect p = GetPoint(i); p.TransformPoint(m); if(!bInitialized) { newBounds.Max = newBounds.Min = p; bInitialized = 1; } else { if(p.x < newBounds.Min.x) newBounds.Min.x = p.x; else if(p.x > newBounds.Max.x) newBounds.Max.x = p.x; if(p.y < newBounds.Min.y) newBounds.Min.y = p.y; else if(p.y > newBounds.Max.y) newBounds.Max.y = p.y; if(p.z < newBounds.Min.z) newBounds.Min.z = p.z; else if(p.z > newBounds.Max.z) newBounds.Max.z = p.z; } } return newBounds; }
void Mesh::Clip(const Plane & plane, SArray< Vec3<double> > & positivePart, SArray< Vec3<double> > & negativePart) const { const size_t nV = GetNPoints(); if (nV == 0) { return; } double d; for (size_t v = 0; v < nV; v++) { const Vec3<double> & pt = GetPoint(v); d = plane.m_a * pt[0] + plane.m_b * pt[1] + plane.m_c * pt[2] + plane.m_d; if (d > 0.0) { positivePart.PushBack(pt); } else if (d < 0.0) { negativePart.PushBack(pt); } else { positivePart.PushBack(pt); negativePart.PushBack(pt); } } }
Double_t RooHistN::getFitRangeNEvt(Double_t xlo, Double_t xhi) const { // Calculate integral of histogram in given range Double_t sum(0) ; for (int i=0 ; i<GetN() ; i++) { Double_t x,y ; #if ROOT_VERSION_CODE >= ROOT_VERSION(4,0,1) GetPoint(i,x,y) ; #else const_cast<RooHistN*>(this)->GetPoint(i,x,y) ; #endif if (x>=xlo && x<=xhi) { sum += y ; } } if (_rawEntries!=-1) { coutW(Plotting) << "RooHistN::getFitRangeNEvt() WARNING: Number of normalization events associated to histogram is not equal to number of events in histogram" << endl << " due cut made in RooAbsData::plotOn() call. Automatic normalization over sub-range of plot variable assumes" << endl << " that the effect of that cut is uniform across the plot, which may be an incorrect assumption. To be sure of" << endl << " correct normalization explicit pass normalization information to RooAbsPdf::plotOn() call using Normalization()" << endl ; sum *= _rawEntries / _entries ; } return sum ; }
// Add a point to gamut descriptor. Point to add is in Lab color space. // GBD is centered on a=b=0 and L*=50 cmsBool CMSEXPORT cmsGDBAddPoint(cmsHANDLE hGBD, const cmsCIELab* Lab) { cmsGDB* gbd = (cmsGDB*) hGBD; cmsGDBPoint* ptr; cmsSpherical sp; // Get pointer to the sector ptr = GetPoint(gbd, Lab, &sp); if (ptr == NULL) return FALSE; // If no samples at this sector, add it if (ptr ->Type == GP_EMPTY) { ptr -> Type = GP_SPECIFIED; ptr -> p = sp; } else { // Substitute only if radius is greater if (sp.r > ptr -> p.r) { ptr -> Type = GP_SPECIFIED; ptr -> p = sp; } } return TRUE; }
vec Line::ClosestPoint(const vec &targetPoint, float *d) const { float u = Dot(targetPoint - pos, dir); if (d) *d = u; return GetPoint(u); }
double NURBSSurface::Getv(double u, CVector r) { double sine = 10000.0; if(u<=0.0) return 0.0; if(u>=1.0) return 0.0; if(r.VAbs()<1.0e-5) return 0.0; int iter=0; double v, v1, v2; r.Normalize(); v1 = 0.0; v2 = 1.0; while(qAbs(sine)>1.0e-4 && iter<200) { v=(v1+v2)/2.0; GetPoint(u, v, t_R); t_R.x = 0.0; t_R.Normalize();//t_R is the unit radial vector for u,v sine = (r.y*t_R.z - r.z*t_R.y); if(sine>0.0) v1 = v; else v2 = v; iter++; } return (v1+v2)/2.0; }
void CIni::SerGetPoint( bool bGet,CPoint & pt, LPCTSTR strEntry, LPCTSTR strSection, CPoint ptDefault) { if(bGet) pt = GetPoint(strEntry,ptDefault,strSection); else WritePoint(strEntry,pt, strSection); }
void Curve::Update() { // calculate length once length = 0.0f; // Approxmate using 100 straight curves int numsegs = 100; // Add lengths of pieces float3 oldpoint, newpoint, movement; for(int i = 0; i < numsegs; i++) { oldpoint = GetPoint(1.0f/numsegs * i); newpoint = GetPoint(1.0f/numsegs * (i + 1)); movement = newpoint - oldpoint; length += movement.Length(); } }
bool PolyLine2::PtIn( const Vec2& pt ) const { int nP = GetNPoints(); if (nP < 3) return false; int nW = 0; // loop through all edges of the polygon for (int i = 0; i < nP; i++) { const Vec2& a = m_Points[i]; const Vec2& b = GetPoint( i + 1 ); if (a.y <= pt.y) { if (b.y > pt.y) { if (pt.leftof( a, b ) > 0.0f) { nW++; } } } else { if (b.y <= pt.y) { if (pt.leftof( a, b ) < 0.0f) { nW--; } } } } return (nW != 0); }
bool VectorPath::FindBezierScale(int32 index, BPoint point, double* scale) const { if (index >= 0 && index < fPointCount && scale) { int maxStep = 1000; double t = 0.0; double dt = 1.0 / maxStep; *scale = 0.0; double min = FLT_MAX; BPoint curvePoint; for (int step = 1; step < maxStep; step++) { t += dt; GetPoint(index, t, curvePoint); double d = agg::calc_distance(curvePoint.x, curvePoint.y, point.x, point.y); if (d < min) { min = d; *scale = t; } } return true; } return false; }
Point Polygon::ClosestPoint(const Point& point) const { if (Intersects(point)) return point; Point closestSoFar = GetPoint(0); for (int i = 0; i < NumPoints(); ++i) { Segment seg(GetPoint(i), GetPoint(i + 1)); Point closestNow = seg.ClosestPoint(point); if (point.IsCloserToFirstThanSecond(closestNow, closestSoFar)) closestSoFar = closestNow; } return closestSoFar; }
void Nightcharts::drawLegend(QPainter *painter) { //double ptext = 25; double angle = palpha; painter->setPen(Qt::SolidLine); switch(cltype) { case Nightcharts::Vertical: { int dist = 5; painter->setBrush(Qt::white); for (int i = pieces.size()-1; i >= 0; i--) { painter->setBrush(pieces[i].rgbColor); float x = lX+dist; float y = lY+dist+i*(painter->fontMetrics().height()+2*dist); painter->drawRect(x,y,painter->fontMetrics().height(),painter->fontMetrics().height()); painter->drawText(x+painter->fontMetrics().height()+dist,y+painter->fontMetrics().height()/2+dist,pieces[i].pname + " - " + QString::number(pieces[i].pPerc)+"%"); } break; } case Nightcharts::Round: for (int i=pieces.size()-1;i>=0;i--) { float len = 100; double pdegree = 3.6*pieces[i].pPerc; angle -= pdegree/2; QPointF p = GetPoint(angle); QPointF p_ = GetPoint(angle, cW+len,cH+len); int q = GetQuater(angle); if (q == 3 || q == 4) { p.setY(p.y()+pW/2); p_.setY(p_.y()+pW/2); } painter->drawLine(p.x(),p.y(),p_.x(),p_.y()); QString label = pieces[i].pname + " - " + QString::number(pieces[i].pPerc)+"%"; float recW = painter->fontMetrics().width(label)+10; float recH = painter->fontMetrics().height()+10; p_.setX(p_.x()-recW/2 + recW/2*cos(angle*M_PI/180)); p_.setY(p_.y()+recH/2 + recH/2*sin(angle*M_PI/180)); painter->setBrush(Qt::white); painter->drawRoundRect(p_.x() ,p_.y(), recW, -recH); painter->drawText(p_.x()+5, p_.y()-recH/2+5, label); angle -= pdegree/2; } break; } }
void PolyLine2::Refine() { int cP = 0; while (cP < m_Points.size()) { const Vec2& pc = GetPoint( cP ); const Vec2& pn = GetPoint( cP + 1 ); if (pc.equal( pn )) { DeletePoint( cP ); } else { cP++; } } }
float3 Circle::ClosestPointToEdge(const float3 &point) const { float3 pointOnPlane = ContainingPlane().Project(point); float3 diff = pointOnPlane - pos; if (diff.IsZero()) return GetPoint(0); // The point is in the center of the circle, all points are equally close. return pos + diff.ScaledToLength(r); }
void SplineSeg3<D> :: LineIntersections (const double a, const double b, const double c, ARRAY < Point<D> > & points, const double eps) const { points.SetSize(0); double t; const double c1 = a*p1(0) - sqrt(2.)*a*p2(0) + a*p3(0) + b*p1(1) - sqrt(2.)*b*p2(1) + b*p3(1) + (2.-sqrt(2.))*c; const double c2 = -2.*a*p1(0) + sqrt(2.)*a*p2(0) -2.*b*p1(1) + sqrt(2.)*b*p2(1) + (sqrt(2.)-2.)*c; const double c3 = a*p1(0) + b*p1(1) + c; if(fabs(c1) < 1e-20) { if(fabs(c2) < 1e-20) return; t = -c3/c2; if((t > -eps) && (t < 1.+eps)) points.Append(GetPoint(t)); return; } const double discr = c2*c2-4.*c1*c3; if(discr < 0) return; if(fabs(discr/(c1*c1)) < 1e-14) { t = -0.5*c2/c1; if((t > -eps) && (t < 1.+eps)) points.Append(GetPoint(t)); return; } t = (-c2 + sqrt(discr))/(2.*c1); if((t > -eps) && (t < 1.+eps)) points.Append(GetPoint(t)); t = (-c2 - sqrt(discr))/(2.*c1); if((t > -eps) && (t < 1.+eps)) points.Append(GetPoint(t)); }
void STLTopology :: SaveBinary (const char* filename, const char* aname) const { ofstream ost(filename); PrintFnStart("Write STL binary file '",filename,"'"); if (sizeof(int) != 4 || sizeof(float) != 4) {PrintWarning("for stl-binary compatibility only use 32 bit compilation!!!");} //specific settings for stl-binary format const int namelen = 80; //length of name of header in file const int nospaces = 2; //number of spaces after a triangle //write header: aname int i, j; char buf[namelen+1]; int strend = 0; for(i = 0; i <= namelen; i++) { if (aname[i] == 0) {strend = 1;} if (!strend) {buf[i] = aname[i];} else {buf[i] = 0;} } FIOWriteString(ost,buf,namelen); PrintMessage(5,"header = ",buf); //RWrite Number of facets int nofacets = GetNT(); FIOWriteInt(ost,nofacets); PrintMessage(5,"NO facets = ", nofacets); float f; char spaces[nospaces+1]; for (i = 0; i < nospaces; i++) {spaces[i] = ' ';} spaces[nospaces] = 0; for (i = 1; i <= GetNT(); i++) { const STLTriangle & t = GetTriangle(i); const Vec<3> & n = t.Normal(); f = n(0); FIOWriteFloat(ost,f); f = n(1); FIOWriteFloat(ost,f); f = n(2); FIOWriteFloat(ost,f); for (j = 1; j <= 3; j++) { const Point3d p = GetPoint(t.PNum(j)); f = p.X(); FIOWriteFloat(ost,f); f = p.Y(); FIOWriteFloat(ost,f); f = p.Z(); FIOWriteFloat(ost,f); } FIOWriteString(ost,spaces,nospaces); } PrintMessage(5,"done"); }
void ContestDijkstra::AddStartEdges() { assert(num_stages <= MAX_STAGES); assert(n_points > 0); const int max_altitude = incremental ? GetMaximumStartAltitude(GetPoint(n_points - 1)) : 0; for (ScanTaskPoint destination(0, 0), end(0, n_points); destination != end; destination.IncrementPointIndex()) { // only add points that are valid for the finish if (!incremental || GetPoint(destination).GetIntegerAltitude() <= max_altitude) LinkStart(destination); } }
void printAllPoint() { int i, j; for (i = 0; i < SSize; i++) { tmpInput = GetPoint(i, SHead); for (j = 0; j < dataDimension; j++) { printf("%d", *(tmpInput->data[j])); } } }
void InputEntity::SetLabel(std::string text) { if(NULL != label) label->SetText(text); else label = new TextEntity(text, FONT_SIZE_NORMAL); SetPoint(GetPoint()); }
Frame PolyLine2::GetBound() const { int nP = GetNPoints(); if (nP == 0) return Frame::null; const Vec2& p0 = GetPoint( 0 ); Frame rect( p0.x, p0.y, p0.x, p0.y ); for (int i = 1; i < nP; i++) { const Vec2& p = GetPoint( i ); if (p.x < rect.x) rect.x = p.x; if (p.y < rect.y) rect.y = p.y; if (p.x > rect.w) rect.w = p.x; if (p.y > rect.h) rect.h = p.y; } rect.w -= rect.x; rect.h -= rect.y; return rect; }