예제 #1
0
static void AdjustObturationPointSource( const AcGePoint3dArray& polygon, const AcGePoint3dArray& ext_polygon, AcGePoint3dArray& ob_pts )
{
    bool isClockWise = ( ClockWise( polygon ) == -1 );

    int n = ob_pts.length();
    int m = polygon.length();
    for( int i = 0; i < n; i++ )
    {
        int pos = FindPointOnPolygon( ob_pts[i], polygon );
        //acutPrintf(_T("\n点源位置:%d"), pos);
        if( pos != -1 )
        {
            int p1 = ( ( pos == 0 ) ? m - 1 : pos - 1 );
            int p2 = pos;
            int p3 = ( ( pos == m - 1 ) ? 0 : pos + 1 );
            ob_pts[i] = ProjectPointOfTwoLine(
                            polygon[p2],
                            polygon[p3],
                            ext_polygon[p2],
                            ext_polygon[p3],
                            ob_pts[i] );

            // 进行将点源坐标向采空区做微小的调整
            ob_pts[i] = MinorAjustPointSource(
                            isClockWise,
                            polygon[p1],  // 前一个点
                            polygon[p2],            // 当前点
                            polygon[p3],      // 下一个点
                            ob_pts[i] );
        }
    }
}
예제 #2
0
void preprocesareInformatii(){
   Points = readFromFile();
   type = testCC(Points);
   direction = ClockWise(Points, pointsType);
   pointsType = ShiftVector(pointsType);
   
}
예제 #3
0
파일: mofang.c 프로젝트: MrChang0/rubik
void start()
{
	ClockWise(1,0,number[0][med]);
	ClockWise(1,0,number[0][med]);
	ClockWise(1,0,number[0][med]);
	ClockWise(3,0,number[1][med]);
	ClockWise(5,0,number[2][med]);
	ClockWise(7,0,number[3][med]);
	while(JudgeToGO(7,number[3][med])!=1);
	
	ClockWise(2,0,number[0][_high]);
	while(JudgeToGO(2,number[0][_high])!=1);
	REG_Write(4,0,number[1][_high]);
	REG_Write(8,0,number[3][_high]);
	Action();
	while(JudgeToGO(8,number[3][_high])!=1);
	ClockWise(6,0,number[2][_high]);
	while(JudgeToGO(6,number[2][_high])!=1);
}
예제 #4
0
// 闭合多边形向内偏移
bool OffSetPolygon( const AcGePoint3dArray& polygon, double offset, bool is_inner, AcGePoint3dArray& offset_polygon )
{
    // 判断多边形方向
    int dir = ClockWise( polygon );
    if( dir == 0 ) return false;

    // 向内或向外???
    int c = ( is_inner ? -1 : 1 );

    // 偏移方向角度
    //		1) 与多边形的方向有关(dir)
    //		2) 与要偏移的方向有关(is_inner)
    double angle = c * dir * PI * 0.5;

    bool ret = true;

    int n = polygon.length();
    for( int i = 0; i < n; i++ )
    {
        int p1 = ( n + i - 1 ) % n, p2 = i % n, p3 = ( i + 1 ) % n;

        // 对点进行偏移
        // 计算偏移向量
        AcGeVector3d v1 = polygon[p2] - polygon[p1];
        v1.normalize();
        v1.rotateBy( angle, AcGeVector3d::kZAxis );

        AcGeVector3d v2 = polygon[p3] - polygon[p2];
        v2.normalize();
        v2.rotateBy( angle, AcGeVector3d::kZAxis );

        // 求两个向量的夹角
        double angle = v1.angleTo( v2 );
        double L = abs( offset / cos( angle * 0.5 ) );

        AcGeVector3d v = v1 + v2;
        v.normalize();

        offset_polygon.append( polygon[p2] + v * L );
    }
    return ret;
}
예제 #5
0
static void AdjustAndExplodeGoafPolygon( const AcDbVoidPtrArray& lines,
        const AcGePoint3dArray& polygons,
        const AcDbIntArray& polygon_counts,
        int k,
        AcGePoint3dArray& spts,
        AcGePoint3dArray& epts,
        AcGeDoubleArray& dirs )
{
    int s = 0;
    for( int i = 0; i < k; i++ )
    {
        s += polygon_counts[i];
    }
    int t = s + polygon_counts[k];

    AcGePoint3dArray goaf_polygon;
    for( int i = s; i < t; i++ )
    {
        goaf_polygon.append( polygons[i] );
    }

    // 调整采空区多边形(向内)
    // 保证点是彼此相连的
    AcGePoint3dArray inner_polygon;
    AdjustPointPolygon( lines, goaf_polygon, inner_polygon, true );

    // 调整采空区多边形(向外)
    // 不保证点是彼此相连的
    AcGePoint3dArray outer_polygon;
    AdjustLinePolygon( lines, goaf_polygon, outer_polygon, false );

    // 分解多边形为直线数组
    ExplodeGoafPolygon( goaf_polygon, inner_polygon, outer_polygon, spts, epts );
    //ExplodeLinePolygon(outer_polygon, spts, epts);

    // 计算方向(垂直分支,向采空区内)
    CaclDirections( ClockWise( goaf_polygon ) == -1, spts, epts, dirs );
}
예제 #6
0
파일: mofang.c 프로젝트: MrChang0/rubik
void left90(uint8_t _ID) 
{
	char ID=2*_ID-1;
	ClockWise(ID,0,number[_ID-1][med]);
	ClockWise(ID,0,number[_ID-1][med]);
	while(JudgeToGO(ID,number[_ID-1][med])!=1);
	
	ClockWise(ID+1,0,number[_ID-1][_high]-8);
	while(JudgeToGO(ID+1,number[_ID-1][_high]-8)!=1);
	
	ClockWise(ID,0,number[_ID-1][high]);
 	while(JudgeToGO(ID,number[_ID-1][high])!=1);
	
  ClockWise(ID+1,0,number[_ID-1][_low]);
	while(JudgeToGO(ID+1,number[_ID-1][_low])!=1);
	
	ClockWise(ID,0,number[_ID-1][med]);
	while(JudgeToGO(ID,number[_ID-1][med])!=1);
	
	ClockWise(ID+1,0,number[_ID-1][_high]);
	while(JudgeToGO(ID+1,number[_ID-1][_high])!=1);
}
예제 #7
0
/*
return a unit vector that bisects the angle formed by three points: a-o-b.
*/
CParticleF
bisector(CParticleF& o, CParticleF& a, CParticleF& b)
{
	CParticleF x = NormalizedDirection(a, o);
	CParticleF y = NormalizedDirection(b, o);
	CParticleF z((x.m_X + y.m_X) / 2, (x.m_Y + y.m_Y) / 2);
	float vx = z.m_X;
	float vy = z.m_Y;
	float len0 = sqrt(vx*vx + vy*vy);
	if (len0 <= 1.0e-5) //this is a colinear point. 
	{
		float ang = GetVisualDirection(b.m_X, b.m_Y, a.m_X, a.m_Y) - PI / 2.0;
		vx = cos(ang);
		vy = sin(ang);
	}
	else
	{
		vx = vx / len0;
		vy = vy / len0;
	}
	CParticleF bs(o.m_X + vx, o.m_Y + vy);

	//There are two bisector directions. 
	//We consistently choose one that is in clock-wise direction.
	vector<CParticleF> pnts(4);
	pnts[0] = o;
	pnts[1] = a;
	pnts[2] = bs;
	pnts[3] = b;
	if (ClockWise(pnts)<0)
	{
		vx = -vx;
		vy = -vy;
	}
	return CParticleF(vx, vy);
}