Beispiel #1
0
double Line2LineAngleDistance(double perDist1, double perDist2, const Point &p1, const Point &p2, const Point &p3, const Point &p4)
{
	if(perDist1 == perDist2)
		return 0;

	double line1 = perDist1 > perDist2 ? (perDist1 - perDist2) : (perDist2 - perDist1);
	double lineOrg = PointDistance(p1.first, p1.second, p2.first, p2.second);
	double lineSeg = PointDistance(p3.first, p3.second, p4.first, p4.second);

	return lineSeg * line1/lineOrg;
}
Beispiel #2
0
double TriangleArea(eiVector &p1, eiVector &p2, eiVector &p3)
{
	double area = 0;  
	double a = 0, b = 0, c = 0, s = 0;  
	a = PointDistance(p1, p2);  
	b = PointDistance(p2, p3);  
	c = PointDistance(p1, p3);  
	s = 0.5 * (a + b + c);  
	area = std::sqrt(s * (s - a) * (s - b) * (s - c));  
	return area;
}
bool CircleVLineCollision(
    float x, float y, float radius,
    float line_x, float line_y1, float line_y2)
{
  if(y < line_y1) {
    float d = PointDistance(x, y, line_x, line_y1);
    return d < radius;
  } else if(y > line_y2) {
    float d = PointDistance(x, y, line_x, line_y2);
    return d < radius;
  } else {
    return fabsf(line_x - x) < radius;
  }
}
bool CircleHLineCollision(
    float x, float y, float radius,
    float line_y, float line_x1, float line_x2)
{
  if(x < line_x1) {
    float d = PointDistance(x, y, line_x1, line_y);
    return d < radius;
  } else if(x > line_x2) {
    float d = PointDistance(x, y, line_x2, line_y);
    return d < radius;
  } else {
    return fabsf(line_y - y) < radius;
  }
}
Beispiel #5
0
int FindNormParts(LineInfo *pLns, AM_ZHERTVY *pZher, cf::Point16 *pBeg,
        cf::Point16 *pEnd, int MinLent) {
	int nNorm, i, Lent;
    cf::Point16 CurBeg, CurEnd;
	nNorm = 0;
	for (i = 0; i <= pZher->nZher; i++) {
		if (i == 0) {
			CurBeg = pLns->A;
		} else {
			CurBeg = pZher->LinEnd[i - 1];
		}
		if (i == pZher->nZher) {
			CurEnd = pLns->B;
		} else {
			CurEnd = pZher->LinBeg[i];
		}

		Lent = (int) PointDistance(CurBeg, CurEnd);
		if (Lent < MinLent)
			continue;
		pBeg[nNorm] = CurBeg;
		pEnd[nNorm] = CurEnd;
		nNorm++;
	}
	return nNorm;
}
Beispiel #6
0
bool PreResult2::EqualLinearTypesF::operator() (PreResult2 const & r1, PreResult2 const & r2) const
{
  // Note! Do compare for distance when filtering linear objects.
  // Otherwise we will skip the results for different parts of the map.
  return (r1.m_geomType == feature::GEOM_LINE &&
          r1.IsEqualCommon(r2) &&
          PointDistance(r1.GetCenter(), r2.GetCenter()) < DIST_SAME_STREET);
}
Beispiel #7
0
bool PreResult2::StrictEqualF::operator() (PreResult2 const & r) const
{
  if (m_r.m_resultType == r.m_resultType && m_r.m_resultType == RESULT_FEATURE)
  {
    if (m_r.IsEqualCommon(r))
      return (PointDistance(m_r.GetCenter(), r.GetCenter()) < DIST_EQUAL_RESULTS);
  }

  return false;
}
Beispiel #8
0
double MDLseq4Line(const deque<Point> &slideWindow, int startIndex, int curIndex)
{
	double LH = log10(PointDistance(slideWindow[startIndex].first, slideWindow[startIndex].second, 
						slideWindow[curIndex].first, slideWindow[curIndex].second)) / log10(2.0);
	
	double LDH = 0.0;

	


	return LH + LDH;
}
Beispiel #9
0
double MDLseq(const deque<Point> &slideWindow, int startIndex, int curIndex)
{
	double LH = log10(PointDistance(slideWindow[startIndex].first, slideWindow[startIndex].second, 
						slideWindow[curIndex].first, slideWindow[curIndex].second)) / log10(2.0);
		
	double LDH = 0.0;
	
	size_t l = curIndex - startIndex;
	/*
	for(size_t i = startIndex; i < l; ++i)
	{
		LDH += Point2LineDistance(slideWindow[i], slideWindow[startIndex], slideWindow[curIndex]);
	}
	*/

	double angleDist = 0.0;
	double perpendicularDist = 0.0;
	Point p3 = slideWindow[startIndex];
	Point p4 = slideWindow[curIndex];
	for(size_t i = startIndex; i < l - 1; ++i)
	{
		Point p1 = slideWindow[i];
		Point p2 = slideWindow[i + 1];
		
		double perDist1 = Point2LineDistance(p1, p3, p4);
		double perDist2 = Point2LineDistance(p2, p3, p4);

		angleDist += Line2LineAngleDistance(perDist1, perDist2, p1, p2, p3, p4);
		perpendicularDist += Line2LinePerpendicularDistance(p1, p2, p3, p4);
	}



	LDH = log10(angleDist) / log10(2.0) + log10(perpendicularDist) / log10(2.0);



	return LH + LDH;
}
Beispiel #10
0
void MakeNormOrderForZher(LineInfo *pLns, AM_ZHERTVY *pZher) {
	int i, k, Dist, best_i, best_dist, a;
    cf::Point16 CurBeg, CurEnd;
	for (k = 0; k < pZher->nZher; k++) {
		if (k == 0) {
			CurBeg = pLns->A;
		} else {
			CurBeg = pZher->LinEnd[k - 1];
		}
		best_dist = 1000000;
		best_i = k;
		for (i = k; i < pZher->nZher; i++) {
			CurEnd = pZher->LinBeg[i];
			Dist = (int) PointDistance(CurBeg, CurEnd);
			if (Dist > best_dist)
				continue;
			best_dist = Dist;
			best_i = i;
		}
		if (best_i == k)
			continue;
		a = pZher->iZher[best_i];
		pZher->iZher[best_i] = pZher->iZher[k];
		pZher->iZher[k] = a;
		a = pZher->LinBeg[best_i].x();
		pZher->LinBeg[best_i].rx() = pZher->LinBeg[k].x();
		pZher->LinBeg[k].rx() = a;
		a = pZher->LinBeg[best_i].y();
		pZher->LinBeg[best_i].ry() = pZher->LinBeg[k].y();
		pZher->LinBeg[k].ry() = a;
		a = pZher->LinEnd[best_i].x();
		pZher->LinEnd[best_i].rx() = pZher->LinEnd[k].x();
		pZher->LinEnd[k].rx() = a;
		a = pZher->LinEnd[best_i].y();
		pZher->LinEnd[best_i].ry() = pZher->LinEnd[k].y();
		pZher->LinEnd[k].ry() = a;
	}
}
Beispiel #11
0
void New_MarkVerifiedLines(void *vLti, Handle hCPage, Rect16 *pRc,
		int *pWhatDo, int nComp, int *nZher, int *iZher, int MaxZher,
		Bool AbleShortVert) {
	int i, n, Lent, ret;
	LineInfo *pLns;
	LinesTotalInfo *pLti;
	AM_ZHERTVY ZherOfLine;
	uint32_t AntiFalse, AntiTrue, AntiPoin;
	Bool WasPointed, WasLongPointed;
	AntiFalse = 0xFFFFFFFF;
	AntiFalse ^= LI_IsFalse;
	AntiTrue = 0xFFFFFFFF;
	AntiTrue ^= LI_IsTrue;
	AntiPoin = 0xFFFFFFFF;
	AntiPoin ^= LI_Pointed;
	pLti = (LinesTotalInfo *) vLti;
	ChoiseQuasiLetters(pRc, pWhatDo, nComp);
	*nZher = 0;
	/*****************  горизонтальная  ******************************/
	n = pLti->Hor.Cnt;
	pLns = pLti->Hor.Lns;
	for (i = 0; i < n; i++) {
		Lent = (int) PointDistance(pLns->A, pLns->B);
		/*  определение отточий - обжалованию не подлежит  *///пора переиграть
		/*		if ( AM_Skip (AM_GetKeyOfRule (RU_VL_U_NoPointedLines)))
		 {
		 if ((pLns->SegCnt==1)&&(pLns->Quality==255)&&(pLns->Thickness==2))
		 {
		 pLns->Flags |= LI_Pointed;
		 pLns++;
		 continue;
		 }
		 if ((pLns->SegCnt==2)&&(pLns->Quality>=240)&&(pLns->Thickness==1))
		 {
		 pLns->Flags |= LI_Pointed;
		 pLns->Flags |= LI_Doubt;
		 pLns++;
		 continue;
		 }
		 }*///Almi 13.09.01
		/*  верификация формальная (для всех)  */
		if (!AM_Skip(AM_GetKeyOfRule(RU_VL_U_NewFormalVerify)))
			FormalVerification(pLns, Lent);
		else
			OldFormalVerification(pLns, Lent);
		/*  верификация по тифу (для коротких)  */
		ret = RV_EMPTY;
		if ((Lent > 60) && (Lent <= 350) && (AM_Skip(AM_GetKeyOfRule(
				RU_VL_U_NoInvestImage))))
			ret = InvestShortLineWithRastr_rv_pne(hCPage, pLns);
		if (ret == RV_NEGATIVE)
			PutNewFlagOfLine(pLns, LI_IsFalse);
		if (ret == RV_POSITIVE)
			PutNewFlagOfLine(pLns, LI_IsTrue);
		/*  верификация по коробкам (для длинных и не отифенных коротких)  */
		if (!AM_Skip(AM_GetKeyOfRule(RU_VL_U_AbleHoriZher))) {
			if (((Lent > 350) || (ret == RV_EMPTY)) && (AM_Skip(
					AM_GetKeyOfRule(RU_VL_U_NoInvestLongLines))))
				InvestLongLineWithBoxes(pLns, pRc, pWhatDo, nComp, nZher,
						iZher, &ZherOfLine, MaxZher, TRUE, Lent);
		}
		pLns++;
	}
	//******** горизонтальные отточия проверим ********//
	pLns = pLti->Hor.Lns;
	WasPointed = FALSE;
	WasLongPointed = FALSE;
	for (i = 0; i < n; i++) {
		if (!(pLns[i].Flags & LI_Pointed))
			continue;
		WasPointed = TRUE;
		if (abs(pLns[i].A.x() - pLns[i].B.x()) > 100)
			WasLongPointed = TRUE;
	}
	if (WasPointed & !WasLongPointed) {
		pLns = pLti->Hor.Lns;
		for (i = 0; i < n; i++) {
			if ((pLns[i].Flags & LI_Pointed))
				pLns[i].Flags &= AntiPoin;
		}
	}
	/*****************  вертикальная  ******************************/
	n = pLti->Ver.Cnt;
	pLns = pLti->Ver.Lns;
	for (i = 0; i < n; i++) {
		Lent = (int) PointDistance(pLns->A, pLns->B);
		if (!AM_Skip(AM_GetKeyOfRule(RU_VL_U_NewFormalVerify)))
			FormalVerification(pLns, Lent);
		else
			OldFormalVerification(pLns, Lent);
		if (AM_Skip(AM_GetKeyOfRule(RU_VL_U_NoInvestLongLines))) {
			if (Lent <= 100)
				if (pLns->Flags & LI_IsFalse)
					pLns->Flags &= AntiFalse;
		}
		if (AM_Skip(AM_GetKeyOfRule(RU_VL_U_NoInvestLongLines))) {
			if (AbleShortVert && (Lent >= 94))
				InvestLongLineWithBoxes(pLns, pRc, pWhatDo, nComp, nZher,
						iZher, &ZherOfLine, MaxZher, FALSE, Lent);
			else if (pLns->Flags & LI_IsTrue)
				pLns->Flags &= AntiTrue;
		}
		pLns++;
	}
}
Beispiel #12
0
double MDLnoseq(const deque<Point> &slideWindow, int startIndex, int curIndex)		//	LDH = 0;
{
	return log10(PointDistance(slideWindow[startIndex].first, slideWindow[startIndex].second, 
						slideWindow[curIndex].first, slideWindow[curIndex].second)) / log10(2.0);
}
Beispiel #13
0
	int run_test_case( int casenum ) {
		switch( casenum ) {
		case 0: {
			int x1                    = -1;
			int y1                    = 0;
			int x2                    = 1;
			int y2                    = 0;
			int expected__[]          = {8, 48 };

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}
		case 1: {
			int x1                    = 1;
			int y1                    = 1;
			int x2                    = -1;
			int y2                    = -1;
			int expected__[]          = {25, -63 };

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}
		case 2: {
			int x1                    = 0;
			int y1                    = 1;
			int x2                    = 2;
			int y2                    = 3;
			int expected__[]          = {41, 65 };

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}
		case 3: {
			int x1                    = 5;
			int y1                    = -4;
			int x2                    = -2;
			int y2                    = 5;
			int expected__[]          = {68, 70 };

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}
		case 4: {
			int x1                    = -50;
			int y1                    = -50;
			int x2                    = 50;
			int y2                    = -50;
			int expected__[]          = {67, 4 };

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}
		case 5: {
			int x1                    = -50;
			int y1                    = 50;
			int x2                    = -49;
			int y2                    = 49;
			int expected__[]          = {73, -25 };

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}

		// custom cases

/*      case 6: {
			int x1                    = ;
			int y1                    = ;
			int x2                    = ;
			int y2                    = ;
			int expected__[]          = ;

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}*/
/*      case 7: {
			int x1                    = ;
			int y1                    = ;
			int x2                    = ;
			int y2                    = ;
			int expected__[]          = ;

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}*/
/*      case 8: {
			int x1                    = ;
			int y1                    = ;
			int x2                    = ;
			int y2                    = ;
			int expected__[]          = ;

			clock_t start__           = clock();
			vector <int> received__   = PointDistance().findPoint( x1, y1, x2, y2 );
			return verify_case( casenum, vector <int>( expected__, expected__ + ( sizeof expected__ / sizeof expected__[0] ) ), received__, clock()-start__ );
		}*/
		default:
			return -1;
		}
	}