Esempio n. 1
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float Up_Down = 0;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        //保证圆弧连接型的圆心坐标为发生改变
        //	motion_data_circle.Center_Point = motion_data1.DisplayTarget;

        if (motion_data1.DisplayTarget.y == motion_data1.Center_Point.y)
        {
            if (motion_data2.DisplayStart.x > motion_data1.Center_Point.x)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                float e = motion_data2.DisplayStart.y - motion_data2.Center_Point.y;
                if (e < 0.00001 && e > -0.00001)
                {
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.LogError ("调试");
                    }
                }
                else
                {
                    if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                        if (k2 > 0)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.Log ( "调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        }
                    }
                }
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                float e = motion_data2.DisplayStart.y - motion_data2.Center_Point.y;
                if (e < 0.00001 && e > -0.00001)
                {
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    }
                }
                else
                {
                    if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                        if (k2 > 0)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.Log ( "调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        }
                    }
                }
            }
        }
        else
        {
            if (motion_data1.DisplayTarget.y > motion_data1.Center_Point.y)           //读一段圆弧终点和圆心所在的圆弧的直线方向向上
            {
                Up_Down = 1;
            }
            else
            {
                Up_Down = -1;
            }

            if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x)           //读一段圆弧终点和圆心所在的圆弧的直线的斜率不存在
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 * Up_Down;
                if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x && motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayTarget.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayTarget.y - Radius2;
                }
                else if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x && motion_data2.Center_Point.y <= motion_data2.DisplayStart.y)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                    //Debug.Log ( "调试");
                }
                else
                {
                    Debug.Log(Up_Down);
                    k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Up_Down / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Up_Down * k2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ( "调试");//待检测//已检测
                }
            }
            else
            {
                k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y) / (motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);
                if (motion_data2.DisplayStart.x > motion_data1.Center_Point.x)
                {
                    motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                        //Debug.Log ( "调试");
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                        if (motion_data2.Center_Point.x < motion_data2.DisplayStart.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            // "调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.Log ( "调试");
                        }
                    }
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                        if (motion_data2.Center_Point.x < motion_data2.DisplayStart.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            // "调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        }
                    }
                }
            }
        }
    }
Esempio n. 2
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)      //圆弧直线
    {
        float k2;
        float b2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R = Vector3.Distance(motion_data1.Center_Point, motion_data1.DisplayTarget);

        if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x && motion_data2.DisplayTarget.y != motion_data2.DisplayStart.y)       //k2不存在
        {
            if (motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
                float a = (R - Radius1) * (R - Radius1);
                float b = Mathf.Pow(motion_data2.DisplayStart.x - motion_data1.Center_Point.x, 2);
                if ((a - b) < 0.000001f)
                {
                    a = b;
                }
                motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - Mathf.Sqrt(a - b);
                //Debug.LogError ("调试");
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
                float a = (R - Radius1) * (R - Radius1);
                float b = Mathf.Pow(motion_data2.DisplayStart.x - motion_data1.Center_Point.x, 2);
                if ((a - b) < 0.000001f)
                {
                    a = b;
                }
                motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + Mathf.Sqrt(a - b);
                //Debug.LogError ("调试");
            }
        }
        else
        {
            k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
            b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);

            float dis01 = (k2 * (motion_data1.Center_Point.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - motion_data1.Center_Point.y) / Mathf.Sqrt(1 + k2 * k2);
            float dis   = Mathf.Abs(dis01);

            if (dis == R)
            {            //k2有正负,可不分情况
                if (motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.LogError ("调试");
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.LogError ("调试");
                }
            }
            else
            {
                if (motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
                {
                    float a = 1 + k2 * k2;
                    float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y);
                    float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y, 2) - (R - Radius1) * (R - Radius1);
                    float d = b * b - 4 * a * c;
                    if (d < 0.000001f)
                    {
                        d = 0;
                    }
                    motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                    motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b2;
                    //Debug.Log ("调试");
                }
                else
                {
                    float a = 1 + k2 * k2;
                    float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y);
                    float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y, 2) - (R - Radius1) * (R - Radius1);
                    float d = b * b - 4 * a * c;
                    if (d < 0.000001f)
                    {
                        d = 0;
                    }
                    motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                    motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b2;
                    //Debug.Log ("调试");
                }
            }
        }
    }
Esempio n. 3
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)        //直线圆弧
    {
        float k1;
        float b1;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R = Vector3.Distance(motion_data2.Center_Point, motion_data2.DisplayStart);

        if (motion_data1.DisplayTarget.x == motion_data1.DisplayStart.x)       //K1不存在
        {
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
                float a = (R - Radius2) * (R - Radius2);
                float b = Mathf.Pow(motion_data2.DisplayStart.x - motion_data2.Center_Point.x, 2);
                if ((a - b) < 0.000001f)               //包括出现负值时
                {
                }
                else
                {
                    motion_data1.DisplayTarget.y = Mathf.Sqrt(a - b) + motion_data2.Center_Point.y;
                }
                Debug.LogError("调试");
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
                float a = (R - Radius2) * (R - Radius2);
                float b = Mathf.Pow(motion_data2.DisplayStart.x - motion_data2.Center_Point.x, 2);
                if ((a - b) < 0.000001f)               //包括出现负值时
                {
                }
                else
                {
                    motion_data1.DisplayTarget.y = -Mathf.Sqrt(a - b) + motion_data2.Center_Point.y;
                }
                //Debug.LogError ("调试");
            }
        }
        else        //K1存在
        {
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);
            b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);

            if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)           //右象限
            {
                float a = 1 + k1 * k1;
                float b = -2 * motion_data2.Center_Point.x + 2 * k1 * (-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b1 - motion_data2.Center_Point.y);
                float c = Mathf.Pow(motion_data2.Center_Point.x, 2) + Mathf.Pow(-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b1 - motion_data2.Center_Point.y, 2) - (R - Radius2) * (R - Radius2);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                motion_data1.DisplayTarget.x = (Mathf.Sqrt(b * b - 4 * a * c) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b1;
                //"调试");
            }
            else            //左象限
            {
                float a = 1 + k1 * k1;
                float b = -2 * motion_data2.Center_Point.x + 2 * k1 * (-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b1 - motion_data2.Center_Point.y);
                float c = Mathf.Pow(motion_data2.Center_Point.x, 2) + Mathf.Pow(-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b1 - motion_data2.Center_Point.y, 2) - (R - Radius2) * (R - Radius2);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                motion_data1.DisplayTarget.x = (-Mathf.Sqrt(b * b - 4 * a * c) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b1;
                //"调试");
            }
        }
    }
Esempio n. 4
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
        float k2;
        float CE;
        float AE;
        float x0;
        float y0;
        float dis;
        float Up_down = 0;

        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R1 = Vector3.Distance(motion_data1.Center_Point, motion_data1.DisplayTarget);
        float R2 = Vector3.Distance(motion_data2.Center_Point, motion_data2.DisplayTarget);

        dis = Vector3.Distance(motion_data1.Center_Point, motion_data2.Center_Point); //两圆弧圆心的中心距

        if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x)              //第一段终点和对应圆心所在直线的斜率不存在且方向向上
        {
            if (motion_data1.DisplayTarget.y > motion_data1.Center_Point.y)
            {
                Up_down = 1;
            }
            else
            {
                Up_down = -1;
            }

            if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x)
            {
                if (motion_data1.DisplayTarget.y > motion_data1.Center_Point.y && motion_data2.DisplayTarget.y < motion_data2.DisplayStart.y)
                {
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1;
                    //Debug.Log ("调试");//
                }
                else if (motion_data1.DisplayTarget.y < motion_data1.Center_Point.y && motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                {
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1;
                    //Debug.Log ("调试");//
                }
                else
                {
                    AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                    float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                    if (CE_Quare < 0)
                    {
                        CE_Quare = 0;
                    }
                    CE = Mathf.Sqrt(CE_Quare);

                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE * Up_down;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE * Up_down;
                    //Debug.Log ("调试");//
                }
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);

                if (k2 == 0)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + AE * Up_down;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + CE * Up_down;
                    //Debug.Log ("调试");//
                }
                else
                {
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    motion_data1.DisplayTarget.x = x0 - CE * Up_down * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 + CE * Up_down / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");//
                }
            }
        }
        else        //第一段终点和对应圆心的所在直线的K1存在
        {
            AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2.0f * dis);
            float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
            if (CE_Quare < 0)
            {
                CE_Quare = 0;
            }
            CE = Mathf.Sqrt(CE_Quare);

            if (motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
            {
                float a = motion_data1.Center_Point.x - motion_data2.Center_Point.x;
                //Debug.Log (a);
                if (a < 0.0001f && a > -0.0001f)               //精度要求
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
                    // "调试");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x > motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");//
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
//						Debug.Log (R1 + "," + R2 + "," + Radius1 + "," + Radius2);
//						Debug.Log (k2);
//						Debug.Log (AE + ",,," + CE);
//						Debug.Log (x0 + ";;;" + y0);
                        //Debug.Log ( "调试");//
                    }
                }
            }
            else
            {
                float a = motion_data1.Center_Point.x - motion_data2.Center_Point.x;
                if (a < 0.0001f && a > -0.0001f)               //精度要求
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
                    //Debug.LogError("调试");//// "调试");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x > motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.LogError("调试");//
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
//						Debug.Log (R1 + "," + R2 + "," + Radius1 + "," + Radius2);
//						Debug.Log (k2);
//						Debug.Log (AE + ",,," + CE);
//						Debug.Log (x0 + ";;;" + y0);
                        //Debug.LogError("调试");//
                    }
                }
            }
        }
    }
Esempio n. 5
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
//		float k1;
        float k2;
//		float b1;
        float b2;
        float Radius1;
        float Radius2;
        float Up_Down;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R = Vector3.Distance(motion_data1.Center_Point, motion_data1.DisplayStart);

        float e = motion_data1.Center_Point.y - motion_data2.DisplayStart.y;

        if (e < 0.0001f && e > -0.0001f)       //精度可能要重新考虑
        {
            if (motion_data1.Center_Point.x < motion_data2.DisplayStart.x)
            {
                if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x)
                {
                    if (motion_data2.DisplayStart.y < motion_data2.DisplayTarget.y)
                    {
                        motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1;                        //补偿半径不同时
                        motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1;                        //补偿半径不同时
                        float f = (R + Radius1) * (R + Radius1) - Mathf.Pow(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x, 2);
                        motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - Mathf.Sqrt(f);
                        //Debug.Log ("调试1");
                    }
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
                    float a = 1 + k2 * k2;
                    float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y);
                    float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                    float d = b * b - 4 * a * c;
                    if (d < 0.000001f)
                    {
                        d = 0;
                    }
                    motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                    motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b2;
                    //Debug.Log ("调试1");
                }
            }
            else
            {
                if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x)
                {
                    if (motion_data2.DisplayStart.y > motion_data2.DisplayTarget.y)
                    {
                        motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1;                        //补偿半径不同时
                        motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y;
                        Debug.Log("调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1;                        //补偿半径不同时
                        float f = (R + Radius1) * (R + Radius1) - Mathf.Pow(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x, 2);
                        motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + Mathf.Sqrt(f);
                        Debug.Log("调试");                         //待测试
                    }
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);

                    float a = 1 + k2 * k2;
                    float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y);
                    float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                    float d = b * b - 4 * a * c;
                    if (d < 0.000001f)
                    {
                        d = 0;
                    }
                    motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                    motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b2;
                    //Debug.Log ("调试1");
                }
            }
        }
        else
        {
            if (motion_data1.Center_Point.y < motion_data2.DisplayStart.y)
            {
                Up_Down = 1;
            }
            else
            {
                Up_Down = -1;
            }

            if (motion_data1.Center_Point.x == motion_data2.DisplayStart.x)
            {
                if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                {
                    motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Up_Down;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + Up_Down * Mathf.Sqrt((R + Radius1) * (R + Radius1) - Mathf.Pow(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x, 2));
                    //Debug.Log ("测试12");
                }
                else
                {
//					if(motion_data2.DisplayStart.y == motion_data2.DisplayTarget.y)
//					{
//						motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x;
//						motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2*Up_Down;
//						Debug.LogError ("调试");
//					}
//					else
//					{
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
                    if (motion_data2.DisplayStart.x < motion_data2.DisplayTarget.x)
                    {
                        float a = 1 + k2 * k2;
                        float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y);
                        float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                        float d = b * b - 4 * a * c;
                        if (d < 0.000001f)
                        {
                            d = 0;
                        }
                        motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                        motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b2;
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        float a = 1 + k2 * k2;
                        float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y);
                        float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                        float d = b * b - 4 * a * c;
                        if (d < 0.000001f)
                        {
                            d = 0;
                        }
                        motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                        motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b2;
                        //Debug.LogError ("调试");
                    }
//					}
                }
            }
            else
            {
//				k1 = (motion_data2.DisplayStart.y - motion_data1.DisplayStart.y)/(motion_data2.DisplayStart.x - motion_data1.DisplayStart.x);
//				b1 = Radius1*Mathf.Sqrt (1 + k1*k1);

                if (motion_data1.Center_Point.x < motion_data2.DisplayStart.x)
                {
                    if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                    {
//						if(motion_data2.DisplayStart.y < motion_data1.Center_Point.y)
//						{
//							motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius2;
//							motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - Mathf.Sqrt ((R + Radius1)*(R + Radius1) - Mathf.Pow (motion_data1.DisplayStart.x - motion_data1.Center_Point.x,2));
//							//Debug.Log ("调试");
//						}
//						else
//						{
                        motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius2 * Up_Down;
                        motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + Up_Down * Mathf.Sqrt((R + Radius1) * (R + Radius1) - Mathf.Pow(motion_data1.DisplayStart.x - motion_data1.Center_Point.x, 2));
                        Debug.Log("测试1");
//						}
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                        b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
                        if (motion_data2.DisplayStart.x < motion_data2.DisplayTarget.x)
                        {
                            float a = 1 + k2 * k2;
                            float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data2.DisplayTarget.x + motion_data2.DisplayTarget.y - b2 - motion_data1.Center_Point.y);
                            float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data2.DisplayTarget.x + motion_data2.DisplayTarget.y - b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                            float d = b * b - 4 * a * c;
                            //Debug.Log (d);
                            if (d < 0.000001f)
                            {
                                d = 0;
                            }
                            motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                            motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b2;
                            Debug.Log("调试1");
                        }
                        else
                        {
                            float a = 1 + k2 * k2;
                            float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y);
                            float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                            float d = b * b - 4 * a * c;
                            //Debug.Log (d);
                            if (d < 0.000001f)
                            {
                                d = 0;
                            }
                            motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                            motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b2;
                            //Debug.Log ("调试1");
                        }
                    }
                }
                else
                {                //Debug.Log ("测试123");
                    if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                    {
                        motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius2 * Up_Down;
                        motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + Up_Down * Mathf.Sqrt((R + Radius1) * (R + Radius1) - Mathf.Pow(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x, 2));
                        //Debug.Log ("测试");
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                        b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
                        if (motion_data2.DisplayStart.x < motion_data2.DisplayTarget.x)
                        {
                            float a = 1 + k2 * k2;
                            float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y);
                            float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                            float d = b * b - 4 * a * c;
                            //Debug.Log (d);
                            if (d < 0.000001f)
                            {
                                d = 0;
                            }
                            motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                            motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b2;
                            //Debug.Log ("调试");
                        }
                        else
                        {
                            float a = 1 + k2 * k2;
                            float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y);
                            float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                            float d = b * b - 4 * a * c;
                            //Debug.Log (d);
                            if (d < 0.000001f)
                            {
                                d = 0;
                            }
                            motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                            motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b2;
                            //Debug.Log ("调试");
                        }
                    }
                }
            }
        }
    }
Esempio n. 6
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)       //直线圆弧
    {
        float k1;
        float b1;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R = Vector3.Distance(motion_data1.DisplayTarget, motion_data2.Center_Point);

        if (motion_data2.DisplayStart.x == motion_data1.DisplayStart.x)
        {        //K1不存在
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)
            {
                float a = motion_data2.Center_Point.y - motion_data2.DisplayStart.y;
                if (a < 0.000001f && a > -0.000001f)
                {
                    motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
                    float e = (R + Radius2) * (R + Radius2) - Mathf.Pow((motion_data1.DisplayTarget.x - motion_data2.Center_Point.x), 2);
                    if (e < 0.000001f)
                    {
                        e = 0;
                    }
                    motion_data1.DisplayTarget.y = -Mathf.Sqrt(e) + motion_data2.Center_Point.y;
                    //Debug.LogError ("调试");
                }
            }
            else
            {
                float a = motion_data2.Center_Point.y - motion_data2.DisplayStart.y;
                if (a < 0.000001f && a > -0.000001f)
                {
                    motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
                    float e = (R + Radius2) * (R + Radius2) - Mathf.Pow((motion_data1.DisplayTarget.x - motion_data2.Center_Point.x), 2);
                    if (e < 0.000001f)
                    {
                        e = 0;
                    }
                    motion_data1.DisplayTarget.y = Mathf.Sqrt(e) + motion_data2.Center_Point.y;
                    //Debug.LogError ("调试");
                }
            }
        }
        else
        {        //K1存在
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);
            b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);
            if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
            {            //右象限
//				Vector3 Direction = motion_data1.DisplayTarget - motion_data1.DisplayStart;
//				Vector3 Direction2 = motion_data2.DisplayStart - motion_data2.Center_Point;
//				float Angle ;
//				Angle = Vector3.Angle (Direction, Direction2);
//				if(Angle > 89.999f && Angle < 90.001f)
//				{
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius2*k1/Mathf.Sqrt (1 + k1*k1);
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius2/Mathf.Sqrt (1 + k1*k1);
//				}
//				else
//				{
                float a = 1 + k1 * k1;
                float b = -2.0f * motion_data2.Center_Point.x + 2.0f * k1 * (-k1 * motion_data2.DisplayStart.x + motion_data2.DisplayStart.y - b1 - motion_data2.Center_Point.y);
                float c = Mathf.Pow(motion_data2.Center_Point.x, 2.0f) + Mathf.Pow((-k1 * motion_data2.DisplayStart.x + motion_data2.DisplayStart.y - b1 - motion_data2.Center_Point.y), 2.0f) - (R + Radius2) * (R + Radius2);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b1;
                Debug.LogError("调试");                         //
//				}
            }
            else
            {            //左象限
//				Vector3 Direction = motion_data1.DisplayTarget - motion_data1.DisplayStart;
//				Vector3 Direction2 = motion_data2.DisplayStart - motion_data2.Center_Point;
//				float Angle ;
//				Angle = Vector3.Angle (Direction, Direction2);
//
//				if(Angle > 89.999f && Angle < 90.001f)
//				{
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius2*k1/Mathf.Sqrt (1 + k1*k1);
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius2/Mathf.Sqrt (1 + k1*k1);
//				}
//				else
//				{
                float a = 1 + k1 * k1;
                float b = -2 * motion_data2.Center_Point.x + 2 * k1 * (-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b1 - motion_data2.Center_Point.y);
                float c = Mathf.Pow(motion_data2.Center_Point.x, 2) + Mathf.Pow(-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b1 - motion_data2.Center_Point.y, 2) - (R + Radius2) * (R + Radius2);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b1;
                Debug.LogError("调试");                         //
//				}
            }
        }
    }
Esempio n. 7
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
//		float k1;
        float k2;
        float CE;
        float AE;
        float x0;
        float y0;
        float dis;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R1 = Vector3.Distance(motion_data2.DisplayStart, motion_data1.Center_Point);
        float R2 = Vector3.Distance(motion_data2.Center_Point, motion_data2.DisplayStart);

        dis = Vector3.Distance(motion_data1.Center_Point, motion_data2.Center_Point);                                                  //两圆心之间的距离

        if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x && motion_data1.DisplayTarget.y > motion_data1.Center_Point.y) //k1不存在
        {
            if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x)
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1;
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                if (k2 == 0)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - AE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + CE;
                    //Debug.Log ("调试");
                }
                else
                {
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
            }
        }
        else if (motion_data1.Center_Point.x == motion_data1.DisplayTarget.x && motion_data1.Center_Point.y > motion_data1.DisplayTarget.y)
        {
            if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x)
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1;
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);

                if (k2 == 0)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + AE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - CE;
                    //Debug.Log ("调试");
                }
                else
                {
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
            }
        }
        else
        {
//			k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y)/(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);

//			if (k1 > 0)
//			{
            if (motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
            {
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                if (motion_data1.Center_Point.x == motion_data2.Center_Point.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
                    Debug.Log("调试");     //已检测
                }                        //待检测
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x < motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        //"调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        //"调试");
                    }
                }
            }
            else
            {
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                if (motion_data1.Center_Point.x == motion_data2.Center_Point.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x > motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        //"调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        //"调试");
                    }
                }
            }
//			}
//			else
//			{
//				if(motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
//				{
//					AE = ((R1 - Radius1)*(R1 - Radius1) - (R2 - Radius2)*(R2 - Radius2) + dis*dis )/(2*dis);
//					CE = Mathf.Sqrt ((R1 - Radius1)*(R1 - Radius1) - AE*AE);
//					if(motion_data1.Center_Point.x == motion_data2.Center_Point.x)
//					{
//						motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
//						motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y)/(motion_data2.Center_Point.x - motion_data1.Center_Point.x);
//						x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//						y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k2;
//						if(motion_data2.Center_Point.x < motion_data1.Center_Point.x)
//						{
//							motion_data1.DisplayTarget.x = x0 - CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 + CE/Mathf.Sqrt (1 + k2*k2);
//							//"调试");
//						}
//						else
//						{
//							motion_data1.DisplayTarget.x = x0 + CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 - CE/Mathf.Sqrt (1 + k2*k2);
//							//"调试");
//						}
//					}
//				}
//				else
//				{
//					AE = ((R1 - Radius1)*(R1 - Radius1) - (R2 - Radius2)*(R2 - Radius2) + dis*dis )/(2*dis);
//					CE = Mathf.Sqrt ((R1 - Radius1)*(R1 - Radius1) - AE*AE);
//					if(motion_data1.Center_Point.x == motion_data2.Center_Point.x)
//					{
//						motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
//						motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y)/(motion_data2.Center_Point.x - motion_data1.Center_Point.x);
//						x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//						y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k2;
//						if(motion_data2.Center_Point.x > motion_data1.Center_Point.x)
//						{
//							motion_data1.DisplayTarget.x = x0 + CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 - CE/Mathf.Sqrt (1 + k2*k2);
//							//"调试");
//						}
//						else
//						{
//							motion_data1.DisplayTarget.x = x0 - CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 + CE/Mathf.Sqrt (1 + k2*k2);
//							//"调试");
//						}
//					}
//				}
//			}
        }
    }
Esempio n. 8
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
//		float k1;
        float k2;
        float CE;
        float AE;
        float x0;
        float y0;
        float dis;

        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R1 = Vector3.Magnitude(motion_data1.DisplayTarget - motion_data1.Center_Point);
        float R2 = Vector3.Magnitude(motion_data2.DisplayTarget - motion_data2.Center_Point);


        dis = Mathf.Sqrt(Mathf.Pow(motion_data1.Center_Point.y - motion_data2.Center_Point.y, 2) + Mathf.Pow(motion_data1.Center_Point.x - motion_data2.Center_Point.x, 2));

        if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x && motion_data1.DisplayTarget.y > motion_data1.Center_Point.y)        //k1不存在且方向向上
        {
            if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x)
            {
                if (motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                {
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1;
                    //Debug.LogError ("调试");
                }
                else
                {
                    AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                    float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                    if (CE_Quare < 0)
                    {
                        CE_Quare = 0;
                    }
                    CE = Mathf.Sqrt(CE_Quare);
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
                    //Debug.LogError ("调试");
                }
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                if (k2 == 0)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + AE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + CE;
                    //Debug.LogError ("调试");
                }
                else
                {
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.LogError ("调试");
                }
            }
        }
        else if (motion_data1.Center_Point.x == motion_data1.DisplayTarget.x && motion_data1.Center_Point.y > motion_data1.DisplayTarget.y)        //k1不存在且方向向下
        {
            if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x)
            {
                if (motion_data2.Center_Point.y < motion_data2.DisplayStart.y)
                {
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1;
                    //Debug.LogError ("调试");
                }
                else
                {
                    AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                    float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                    if (CE_Quare < 0)
                    {
                        CE_Quare = 0;
                    }
                    CE = Mathf.Sqrt(CE_Quare);
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
                    //Debug.LogError ("调试");
                }
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                if (k2 == 0)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - AE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - CE;
                    //Debug.LogError ("调试");
                }
                else
                {
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    //Debug.Log (x0 + "," + y0);
                    motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.LogError ("调试");
                }
            }
        }
        else        //k1存在
        {
//			k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y)/(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);
//			float y2 = k1*(motion_data2.Center_Point.x - motion_data1.DisplayTarget.x) + motion_data1.DisplayTarget.y;

//			if (k1 > 0)
//			{
            if (motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
            {
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                float a = motion_data1.Center_Point.x - motion_data2.Center_Point.x;
                if (a > -0.0001f && a < 0.0001f)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
                    //Debug.Log ("调试");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x < motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        //"调试");
                    }
                }
            }
            else
            {
                AE = ((R1 - Radius1) * (R1 - Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);

                float a = motion_data1.Center_Point.x - motion_data2.Center_Point.x;
                if (a > -0.0001 && a < 0.0001)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
                    //Debug.Log ("调试");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x > motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                }
            }
//			}
//			else//小于等于o
//			{
//				if(motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
//				{
//					AE = ((R1 - Radius1)*(R1 - Radius1) - (R2 + Radius2)*(R2 + Radius2) + dis*dis )/(2*dis);
//					CE = Mathf.Sqrt ((R1 - Radius1)*(R1 - Radius1) - AE*AE);
//					float a = motion_data1.Center_Point.x - motion_data2.Center_Point.x;
//					if(a > -0.0001 && a < 0.0001)
//					{
//						motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
//						motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
//						//Debug.Log ("调试");
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y)/(motion_data2.Center_Point.x - motion_data1.Center_Point.x);
//						x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//						y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k2;
//						if(motion_data2.Center_Point.x < motion_data1.Center_Point.x)
//						{
//							Debug.Log (x0 + "," + y0);
//							motion_data1.DisplayTarget.x = x0 + CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 - CE/Mathf.Sqrt (1 + k2*k2);
//							Debug.Log ("调试");
//						}
//						else
//						{
//							motion_data1.DisplayTarget.x = x0 - CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 + CE/Mathf.Sqrt (1 + k2*k2);
//							//Debug.Log ("调试");
//						}
//					}
//
//				}
//				else
//				{
//					AE = ((R1 - Radius1)*(R1 - Radius1) - (R2 + Radius2)*(R2 + Radius2) + dis*dis )/(2*dis);
//					CE = Mathf.Sqrt ((R1 - Radius1)*(R1 - Radius1) - AE*AE);
//					float a = motion_data1.Center_Point.x - motion_data2.Center_Point.x;
//					if(a > -0.0001 && a < 0.0001)
//					{
//						motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
//						motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
//						Debug.Log ("调试");
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y)/(motion_data2.Center_Point.x - motion_data1.Center_Point.x);
//						x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//						y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k2;
//
//						if(motion_data2.Center_Point.x > motion_data1.Center_Point.x)
//						{
//							motion_data1.DisplayTarget.x = x0 - CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 + CE/Mathf.Sqrt (1 + k2*k2);
//							//"调试");
//						}
//						else
//						{
//							motion_data1.DisplayTarget.x = x0 + CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 - CE/Mathf.Sqrt (1 + k2*k2);
//							Debug.Log ("调试");
//						}
//					}
//				}
//			}
        }
    }
Esempio n. 9
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
//		float k1;
        float k2;
        float CE;
        float AE;
        float x0;
        float y0;
        float dis;

        float R1 = Vector3.Distance(motion_data1.DisplayTarget, motion_data1.Center_Point);
        float R2 = Vector3.Distance(motion_data2.DisplayTarget, motion_data2.Center_Point);

        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        dis = Vector3.Distance(motion_data1.Center_Point, motion_data2.Center_Point);                                                  //两圆心坐标之间的距离

        if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x && motion_data1.DisplayTarget.y > motion_data1.Center_Point.y) //第一段终点和对应所在直线的k1不存在,并且方向向上
        {
            if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x && motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1;
                //Debug.LogError ("调试");
            }
            else if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x && motion_data2.DisplayTarget.y < motion_data2.DisplayStart.y)
            {
                AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2.0F * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
                motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
                //Debug.LogError ("调试");
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                if (k2 == 0)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - AE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + CE;
                    //Debug.LogError ("调试");
                }
                else
                {
                    motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.LogError ("调试");
                }
            }
        }
        else if (motion_data1.Center_Point.x == motion_data1.DisplayTarget.x && motion_data1.Center_Point.y > motion_data1.DisplayTarget.y)        //第一段终点与对应圆心所在直线k1不存在并且方向向下
        {
            //左侧象限是有效区域
            if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x && motion_data2.DisplayTarget.y < motion_data2.DisplayStart.y)            //第二段起点和对应圆心所在直线的k2不存在
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1;
                Debug.LogError("调试");
            }
            else if (motion_data2.Center_Point.x == motion_data2.DisplayTarget.x && motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
            {
                AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + CE;
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.y + AE;
                Debug.LogError("调试");
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                CE = Mathf.Sqrt((R1 + Radius1) * (R1 + Radius1) - AE * AE);
                x0 = motion_data1.Center_Point.x - (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                if (k2 < 0.000001f && k2 > -0.000001f)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + AE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - CE;
                    //Debug.LogError ("调试");
                }
                else
                {
                    motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                    Debug.LogError("调试");
                }
            }
        }
        else        //第一段终点和对应圆心所在直线的K1存在
        {
//			k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y)/(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);
//			if (k1 > 0)
//			{
            if (motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
            {
                AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 + Radius1) * (R1 + Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);

                if (motion_data2.Center_Point.x == motion_data1.Center_Point.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
                    //Debug.LogError ("调试");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x > motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        Debug.LogError("调试");
                    }
                }
            }
            else
            {
                AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 - Radius2) * (R2 - Radius2) + dis * dis) / (2 * dis);
                float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
                if (CE_Quare < 0)
                {
                    CE_Quare = 0;
                }
                CE = Mathf.Sqrt(CE_Quare);
                if (motion_data2.Center_Point.x == motion_data1.Center_Point.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
                    Debug.LogError("调试");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data2.Center_Point.x > motion_data1.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        Debug.LogError("调试");
                    }
                }
            }
//			}
//			else//k1 < 0
//			{
//				if(motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
//				{
//					AE = ((R1 + Radius1)*(R1 + Radius1) - (R2 - Radius2)*(R2 - Radius2) + dis*dis )/(2*dis);
//					CE = Mathf.Sqrt ((R1 + Radius1)*(R1 + Radius1) - AE*AE);
//
//					if(motion_data2.Center_Point.x == motion_data1.Center_Point.x)
//					{
//						motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
//						motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
//						//调试过
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y)/(motion_data2.Center_Point.x - motion_data1.Center_Point.x);
//						x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//						y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k2;
//
//						if(motion_data2.Center_Point.x > motion_data1.Center_Point.x)
//						{
//							motion_data1.DisplayTarget.x = x0 + CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 - CE/Mathf.Sqrt (1 + k2*k2);
//						//Debug.LogError ("调试");
//						}
//						else
//						{
//							motion_data1.DisplayTarget.x = x0 - CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 + CE/Mathf.Sqrt (1 + k2*k2);
//							Debug.LogError ("调试");
//						}
//					}
//				}
//				else
//				{
//					AE = ((R1 + Radius1)*(R1 + Radius1) - (R2 - Radius2)*(R2 - Radius2) + dis*dis )/(2*dis);
//					CE = Mathf.Sqrt ((R1 + Radius1)*(R1 + Radius1) - AE*AE);
//					if(motion_data2.Center_Point.x == motion_data1.Center_Point.x)
//					{
//						motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
//						motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y)/(motion_data2.Center_Point.x - motion_data1.Center_Point.x);
//						x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//						y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k2;
//
//						if(motion_data2.Center_Point.x > motion_data1.Center_Point.x)
//						{
//							motion_data1.DisplayTarget.x = x0 + CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 - CE/Mathf.Sqrt (1 + k2*k2);
//						Debug.LogError ("调试");
//						}
//						else
//						{
//							motion_data1.DisplayTarget.x = x0 - CE*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data1.DisplayTarget.y = y0 + CE/Mathf.Sqrt (1 + k2*k2);
//						//Debug.LogError ("调试");
//						}
//					}
//				}
//			}
        }
    }
Esempio n. 10
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)      //圆弧直线G03G01内角
    {
        float k1;
        float k2;
        float Up_Down = 0;

        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);


        if (motion_data1.DisplayTarget.y == motion_data1.Center_Point.y)
        {
            if (motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius2;
                    motion_data_circle.DisplayTarget.y = motion_data1.DisplayTarget.y;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data1.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data1.Center_Point.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius2;
                    motion_data_circle.DisplayTarget.y = motion_data1.DisplayTarget.y;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data1.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data1.Center_Point.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    Debug.Log("调试");
                }
            }
        }
        else
        {
            if (motion_data1.DisplayTarget.y > motion_data1.Center_Point.y)
            {
                Up_Down = 1;
            }
            else if (motion_data1.DisplayTarget.y < motion_data1.Center_Point.y)
            {
                Up_Down = -1;
            }

            if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x)           //第一段终点和圆心所在的直线的斜率不存在
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Up_Down;
                if (motion_data2.DisplayStart.y == motion_data2.DisplayTarget.y)
                {
                    motion_data_circle.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data_circle.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius2 * Up_Down;
                    Debug.Log("调试");
                }
                else
                {
                    if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)                   //第二段直线的斜率不存在
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Up_Down;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                        if (motion_data2.DisplayStart.x > motion_data2.DisplayTarget.x)                        //第二段直线垂直直线的右侧
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            Debug.Log("调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            Debug.Log("调试");
                        }
                    }
                }
            }
            else if (motion_data2.DisplayStart.x > motion_data1.Center_Point.x)           //第一段圆弧终点与圆心所在的垂直直线的右侧
            {
                k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y) / (motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);

                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Up_Down;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    if (motion_data2.DisplayTarget.x < motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                }
            }
            else
            {
                k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y) / (motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);

                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Up_Down;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    if (motion_data2.DisplayTarget.x < motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                }
            }
        }
    }
Esempio n. 11
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        if (motion_data1.DisplayTarget.x == motion_data1.DisplayStart.x)       //第一段直线的k1不存在
        {
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)    //第一段直线的矢量方向向上
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//		        motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                }
            }
            else            //第一段直线的矢量方向垂直向下
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//		        motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                }
            }
        }
        else        //第一段直线k1存在
        {
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);

            if (k1 == 0)
            {
                int Left_Right_Array;
                if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
                {
                    Left_Right_Array = 1;
                }
                else
                {
                    Left_Right_Array = -1;
                }

//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Left_Right_Array;

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
                    if (motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                        //Debug.Log ("调试");
                    }
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Left_Right_Array / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Left_Right_Array * k2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试1");
                }
            }
            else if (motion_data2.DisplayStart.x > motion_data1.DisplayStart.x)           //右侧象限
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 / Mathf.Sqrt(1 + k1 * k1);

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
                    if (motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;                             //不具有镜像特征
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;                             //不具有镜像特征
                        Debug.Log("调试");
                    }
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试1");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                }
            }
            else            //左侧象限
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 / Mathf.Sqrt(1 + k1 * k1);

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
                    if (motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;                             //不具有镜像特征
                        Debug.Log("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;                             //不具有镜像特征
                        Debug.Log("调试");
                    }
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                }
            }
        }
    }
Esempio n. 12
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float b1;
        float b2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        if (motion_data1.DisplayStart.x == motion_data1.DisplayTarget.x && motion_data1.DisplayTarget.x == motion_data2.DisplayTarget.x)       //K1不存在,k2不存在
        {
            if (motion_data2.DisplayTarget.y > motion_data1.DisplayTarget.y && motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                Debug.LogError("测试");
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                Debug.LogError("测试");
            }
        }
        else if (motion_data1.DisplayStart.x == motion_data1.DisplayTarget.x && motion_data1.DisplayTarget.x != motion_data2.DisplayTarget.x) //K1不存在,k2存在
        {
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)                                                                   //第一二点重合的时候
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
                k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
                motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b2;
                //Debug.LogError ("测试");
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayStart.x - Radius1;
                k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
                motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b2;
                //Debug.LogError ("测试");
            }
        }
        else if (motion_data1.DisplayTarget.x == motion_data2.DisplayTarget.x && motion_data1.DisplayTarget.x != motion_data1.DisplayStart.x) //K2不存在,k1存在
        {
            if (motion_data2.DisplayTarget.y > motion_data1.DisplayTarget.y)                                                                  //第一二点重合的时候
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
                k1 = (motion_data2.DisplayStart.y - motion_data1.DisplayStart.y) / (motion_data2.DisplayStart.x - motion_data1.DisplayStart.x);
                b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b1;
                //Debug.LogError ("测试");
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
                k1 = (motion_data2.DisplayStart.y - motion_data1.DisplayStart.y) / (motion_data2.DisplayStart.x - motion_data1.DisplayStart.x);
                b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b1;
                //Debug.LogError ("测试");
            }
        }
        else         //K2存在,k1存在
        {
            k1 = (motion_data2.DisplayStart.y - motion_data1.DisplayStart.y) / (motion_data2.DisplayStart.x - motion_data1.DisplayStart.x);
            k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
            b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
            b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);

            if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
            {
                if (motion_data2.DisplayTarget.x > motion_data1.DisplayTarget.x)
                {
                    motion_data1.DisplayTarget.x = (-b2 + b1) / (k1 - k2) + motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b1;
                }
                else
                {
                    motion_data1.DisplayTarget.x = (b2 + b1) / (k1 - k2) + motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b1;
                }
            }
            else
            {
                if (motion_data2.DisplayTarget.x > motion_data1.DisplayTarget.x)
                {
                    motion_data1.DisplayTarget.x = (-b2 - b1) / (k1 - k2) + motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b1;
                }
                else
                {
                    motion_data1.DisplayTarget.x = (b2 - b1) / (k1 - k2) + motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b1;
                }
            }
        }
    }
Esempio n. 13
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
//		float k1;
        float k2;
        float CE;
        float AE;
        float x0;
        float y0;
        float dis;
        float Up_down = 0;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R1 = Vector3.Distance(motion_data1.Center_Point, motion_data1.DisplayTarget);
        float R2 = Vector3.Distance(motion_data2.Center_Point, motion_data2.DisplayTarget);

        dis = Vector3.Distance(motion_data1.Center_Point, motion_data2.Center_Point);

        if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x)        //k1不存在且方向向上
        {
            if (motion_data1.DisplayTarget.y > motion_data1.Center_Point.y)
            {
                Up_down = 1;
            }
            else
            {
                Up_down = -1;
            }


            AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
            float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
            if (CE_Quare < 0)
            {
                CE_Quare = 0;
            }
            CE = Mathf.Sqrt(CE_Quare);

            if (motion_data2.Center_Point.x == motion_data1.DisplayTarget.x)
            {
                if (dis < R1 + R2)
                {
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Up_down;
                    //Debug.Log ("调试1");
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE * Up_down;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE * Up_down;
                    //Debug.Log ("调试1");
                }
            }
            else
            {
                k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);

                if (k2 == 0)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + AE * Up_down;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + CE * Up_down;
                    //Debug.Log ("调试1");
                }
                else
                {
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    motion_data1.DisplayTarget.x = x0 - CE * k2 * Up_down / Mathf.Sqrt(1 + k2 * k2);
                    motion_data1.DisplayTarget.y = y0 + CE * Up_down / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试1");
                }
            }
        }
        else
        {
//			k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y)/(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);
//			float y2 = k1*(motion_data2.Center_Point.x - motion_data1.DisplayTarget.x) + motion_data1.DisplayTarget.y;
            AE = ((R1 + Radius1) * (R1 + Radius1) - (R2 + Radius2) * (R2 + Radius2) + dis * dis) / (2 * dis);
            float CE_Quare = (R1 - Radius1) * (R1 - Radius1) - AE * AE;
            if (CE_Quare < 0)
            {
                CE_Quare = 0;
            }
            CE = Mathf.Sqrt(CE_Quare);

            if (motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)
            {
                //Debug.Log (y2 - motion_data2.Center_Point.y);
//				if (y2 == motion_data2.Center_Point.y && motion_data2.Center_Point.x > motion_data1.DisplayTarget.x)
//				{
//					Debug.Log (motion_data1.DisplayTarget.x + "," + motion_data1.DisplayTarget.y);
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1*k1/Mathf.Sqrt (1 + k1*k1) ;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1/Mathf.Sqrt (1 + k1*k1);
//					Debug.Log ("调试1");
//				}
//				else if (y2 == motion_data2.Center_Point.y && motion_data2.Center_Point.x < motion_data1.DisplayTarget.x)
//				{
//					x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//					y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k1;
//					motion_data1.DisplayTarget.x = x0 + CE*k1/Mathf.Sqrt (1 + k1*k1);
//					motion_data1.DisplayTarget.y = y0 - CE/Mathf.Sqrt (1 + k1*k1);
//					Debug.Log ("调试");
//				}
//				else
//				{
                if (motion_data1.Center_Point.x == motion_data2.Center_Point.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x + CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + AE;
                    //Debug.Log ("调试1");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data1.Center_Point.x < motion_data2.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试1");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试1");
                    }
                }
//				}
            }
            else
            {
//				if (y2 == motion_data2.Center_Point.y && motion_data2.Center_Point.x < motion_data1.DisplayTarget.x)
//				{
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1/Mathf.Sqrt (1 + k1*k1) ;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1*k1/Mathf.Sqrt (1 + k1*k1);
//				}
//				else if (y2 == motion_data2.Center_Point.y && motion_data2.Center_Point.x < motion_data1.DisplayTarget.x)
//				{
//					x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x)*AE/dis;
//					y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x)*k1;
//					motion_data1.DisplayTarget.x = x0 - CE*k1/Mathf.Sqrt (1 + k1*k1);
//					motion_data1.DisplayTarget.y = y0 + CE/Mathf.Sqrt (1 + k1*k1);
//					Debug.Log ("调试");
//				}
//				else
//				{
                if (motion_data1.Center_Point.x == motion_data2.Center_Point.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.Center_Point.x - CE;
                    motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - AE;
                    //Debug.Log ("调试1");
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data1.Center_Point.y) / (motion_data2.Center_Point.x - motion_data1.Center_Point.x);
                    x0 = motion_data1.Center_Point.x + (motion_data2.Center_Point.x - motion_data1.Center_Point.x) * AE / dis;
                    y0 = motion_data1.Center_Point.y + (x0 - motion_data1.Center_Point.x) * k2;
                    if (motion_data1.Center_Point.x < motion_data2.Center_Point.x)
                    {
                        motion_data1.DisplayTarget.x = x0 + CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 - CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试1");
                    }
                    else
                    {
                        motion_data1.DisplayTarget.x = x0 - CE * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data1.DisplayTarget.y = y0 + CE / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试1");
                    }
                }
//				}
            }
        }
    }
Esempio n. 14
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)      //直线圆弧
    {
        float k1;
        float k2;
        int   Up_Down = 0;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        if (motion_data1.DisplayTarget.y == motion_data1.DisplayStart.y)
        {
            if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1;
                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data1.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.LogError ("调试");
                }
            }
            else
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1;

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius2;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.LogError ("调试");
                }
            }
        }
        else
        {
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)           //方向向上
            {
                Up_Down = 1;
            }
            else if (motion_data1.DisplayTarget.y < motion_data1.DisplayStart.y)
            {
                Up_Down = -1;
            }

            if (motion_data1.DisplayTarget.x == motion_data1.DisplayStart.x)           ////第一段直线K1不存在
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 * Up_Down;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;

                if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Up_Down;
                    //Debug.Log ("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.x) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                    if (motion_data2.Center_Point.x < motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                }
            }
            else            //第一段直线K1存在
            {
                k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);
                if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Up_Down;
                        Debug.LogError("调试");
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                        if (motion_data2.DisplayStart.x < motion_data2.Center_Point.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            Debug.LogError("调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.LogError ("调试");
                        }
                    }
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Up_Down;
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                        if (motion_data2.DisplayStart.x < motion_data2.Center_Point.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.LogError ("调试");
                        }
                        else
                        {
                            Debug.LogError("调试");
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        }
                    }
                }
            }
        }
    }
Esempio n. 15
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)       //圆弧直线G02G01内角
    {
        float k2;
        float b2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        float R = Vector3.Distance(motion_data1.Center_Point, motion_data1.DisplayStart);

        //第二段直线的斜率不存在
        if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x && motion_data2.DisplayTarget.y != motion_data2.DisplayStart.y)
        {
            if (motion_data2.DisplayTarget.y > motion_data1.DisplayTarget.y)           //第二条直线垂直向上
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
                float a = (R + Radius2) * (R + Radius2);
                float b = Mathf.Pow(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x, 2);
                if ((a - b) < 0.000001f)               //保证精度
                {
                    a = b;
                }
                motion_data1.DisplayTarget.y = motion_data1.Center_Point.y - Mathf.Sqrt(a - b);
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
                float a = (R + Radius2) * (R + Radius2);
                float b = Mathf.Pow(motion_data1.DisplayTarget.x - motion_data1.Center_Point.x, 2);
                if ((a - b) < 0.000001f)
                {
                    a = b;
                }
                motion_data1.DisplayTarget.y = motion_data1.Center_Point.y + Mathf.Sqrt(a - b);
            }
        }
        else        //第二段直线的斜率存在
        {
            //k2存在
            k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
            b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
            if (motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
            {
                float a = 1 + k2 * k2;
                float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y);
                float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b2;
            }
            else
            {
                float a = 1 + k2 * k2;
                float b = -2 * motion_data1.Center_Point.x + 2 * k2 * (-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y);
                float c = Mathf.Pow(motion_data1.Center_Point.x, 2) + Mathf.Pow(-k2 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b2 - motion_data1.Center_Point.y, 2) - (R + Radius1) * (R + Radius1);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b2;
            }
        }
    }
Esempio n. 16
0
    //
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float b1;
        float b2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        //K1不存在,k2不存在
        if (motion_data1.DisplayStart.x == motion_data1.DisplayTarget.x && motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
        {        //档半径变化时,补偿半径12可能会发生变化
            if (motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y && motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)
            {
                motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1;
                motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y;
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1;
                motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y;
            }
        }
        else if (motion_data1.DisplayStart.x == motion_data1.DisplayTarget.x && motion_data2.DisplayStart.x != motion_data2.DisplayTarget.x)       //K1不存在,k2存在
        {
            k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
            b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);

            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)           //第一条直线向上
            {
                motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1;
                motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b2;
            }
            else            //第一条直线向下
            {
                motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1;
                motion_data1.DisplayTarget.y = k2 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b2;
            }
        }
        else if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x && motion_data2.DisplayStart.x != motion_data1.DisplayStart.x)       //K2不存在,k1存在
        {
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);
            b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);

            if (motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)           //第二条直线方向向上
            {
                motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2;
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b1;
            }
            else             //第二条直线向下
            {
                //调试过Debug.LogWarning ("GG");
                motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b1;
            }
        }
        else         //K2存在,k1存在
        {
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);
            k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
            b2 = Radius2 * Mathf.Sqrt(1 + k2 * k2);
            b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);

            if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)           //右侧象限
            {
                // "调试");
                if (motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
                {
                    motion_data1.DisplayTarget.x = (b2 - b1) / (k1 - k2) + motion_data2.DisplayStart.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b1;
                }
                else
                {
                    motion_data1.DisplayTarget.x = (-b2 - b1) / (k1 - k2) + motion_data2.DisplayStart.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y + b1;
                }
            }
            else             //左侧象限
            {
                if (motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
                {
                    motion_data1.DisplayTarget.x = (b2 + b1) / (k1 - k2) + motion_data2.DisplayStart.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b1;
                }
                else
                {
                    motion_data1.DisplayTarget.x = (-b2 + b1) / (k1 - k2) + motion_data2.DisplayStart.x;
                    motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data2.DisplayStart.y - b1;
                }
            }
        }
    }
Esempio n. 17
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float Radius1;
        float Radius2;
        float Up_Down = 0;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x)       //第一段圆弧终点和圆心的直线k1不存在
        {
            if (motion_data1.DisplayTarget.y > motion_data1.Center_Point.y)
            {
                Up_Down = 1;
            }
            else
            {
                Up_Down = -1;
            }

//			motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
            motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 * Up_Down;

            if (motion_data2.DisplayTarget.y == motion_data1.DisplayTarget.y && motion_data2.DisplayTarget.x < motion_data1.DisplayStart.x)
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius2;
            }
            else if (motion_data2.DisplayTarget.y == motion_data1.DisplayTarget.y && motion_data2.DisplayTarget.x > motion_data1.DisplayStart.x)
            {
                motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                Debug.Log("调试");
            }
            else
            {
                if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * Up_Down;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    //Debug.Log ("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);

                    if (motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.Log("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                }
            }
        }
        else if (motion_data1.DisplayTarget.y == motion_data1.Center_Point.y)       //第一段圆弧半径所在的直线的斜率为零
        {
            if (motion_data1.DisplayTarget.x < motion_data1.Center_Point.x)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//		        motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y ;
                Debug.Log("调试");

                if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    Debug.Log("调试");
                }
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//		        motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y ;

                if (motion_data2.DisplayTarget.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    Debug.Log("调试");
                }
            }
        }
        else        //第一段圆弧终点处半径所在的直线斜率不为零且存在
        {
            k1 = (motion_data1.DisplayTarget.y - motion_data1.Center_Point.y) / (motion_data1.DisplayTarget.x - motion_data1.Center_Point.x);

//			if(k1 > 0)
//			{
            if (motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)                   //偏向右象限
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                //Debug.Log ("调试");
                if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                {
                    if (motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        Debug.Log("调试");
                    }
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    if (motion_data2.DisplayStart.x < motion_data2.DisplayTarget.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.Log ("调试");
                    }
                }
            }
            else                     //偏向左象限
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                {
                    if (motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.Log ("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        Debug.Log("调试");
                    }
                }
                else if (motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    Debug.Log("调试");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    //"调试");
                }
            }
//			}
//			else
//			{
//				if(motion_data1.DisplayTarget.x > motion_data1.Center_Point.x)//偏向右侧象限
//				{
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x -  Radius1/Mathf.Sqrt (1 + k1*k1);
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y -  Radius1*k1/Mathf.Sqrt (1 + k1*k1);
//					//Debug.Log ("调试");
//					if(motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
//					{
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x +  Radius2;
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
//						//"调试");
//					}
//					else
//					{
//						k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y)/(motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
//						if(motion_data2.DisplayStart.x < motion_data2.DisplayTarget.x)
//						{
//							motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x -  Radius2*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y +  Radius2/Mathf.Sqrt (1 + k2*k2);
//						}
//						else
//						{
//							motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x +  Radius2*k2/Mathf.Sqrt (1 + k2*k2);
//							motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y -  Radius2/Mathf.Sqrt (1 + k2*k2);
//							//Debug.Log ("调试");
//						}
//					}
//				}
//				else//偏向左侧象限
//				{
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x +  Radius1/Mathf.Sqrt (1 + k1*k1);
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y +  Radius1*k1/Mathf.Sqrt (1 + k1*k1);
//					//Debug.Log ("调试");
//
//					if(motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
//					{
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x -  Radius2;
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
//						Debug.Log ("调试");
//					}
//					else if(motion_data2.DisplayTarget.x > motion_data2.DisplayStart.x)
//					{
//						k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y)/(motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x -  Radius2*k2/Mathf.Sqrt (1 + k2*k2);
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y +  Radius2/Mathf.Sqrt (1 + k2*k2);
//						Debug.Log ("调试");
//					}
//					else
//					{
//						k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y)/(motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
//						//Debug.Log ("调试");
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x +  Radius2*k2/Mathf.Sqrt (1 + k2*k2);
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y -  Radius2/Mathf.Sqrt (1 + k2*k2);
//					}
//				}
//			}
        }
    }
Esempio n. 18
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float Up_Down = 0;

        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        //保证圆弧连接型的圆心坐标为发生改变
        motion_data_circle.Center_Point = motion_data1.DisplayTarget;

        if (motion_data1.DisplayTarget.y == motion_data1.Center_Point.y)
        {
            if (motion_data2.DisplayStart.x > motion_data1.Center_Point.x)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                }
                else
                {
                    k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    }
                }                //待测试
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                if (motion_data2.Center_Point.x == motion_data2.DisplayStart.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                }
                else
                {
                    k2 = (motion_data2.DisplayStart.y - motion_data2.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data2.Center_Point.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    }
                }
            }
        }
        else
        {
            if (motion_data1.DisplayTarget.y > motion_data1.Center_Point.y)           //第一段圆弧终点和圆心所在直线方向向上
            {
                Up_Down = 1;
            }
            else
            {
                Up_Down = -1;
            }

            if (motion_data1.DisplayTarget.x == motion_data1.Center_Point.x)            //第一段圆弧终点和圆心所在直线的斜率不存在
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Up_Down;

                if (motion_data2.Center_Point.x == motion_data1.Center_Point.x)               //圆心连线的斜率不存在
                {
                    motion_data_circle.DisplayTarget.x = motion_data1.DisplayTarget.x;
                    motion_data_circle.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius2 * Up_Down;
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Up_Down / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 * Up_Down / Mathf.Sqrt(1 + k2 * k2);
                }
            }
            else
            {
                k1 = (motion_data2.DisplayStart.y - motion_data1.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data1.Center_Point.x);
                if (motion_data1.Center_Point.x < motion_data2.DisplayStart.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data1.Center_Point.x == motion_data2.Center_Point.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayTarget.y - Radius2;
                    }
                    else
                    {
                        k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                        if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.Log ("调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.Log ("调试");
                        }
                    }
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data1.Center_Point.x == motion_data2.Center_Point.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayTarget.y + Radius2;
                    }
                    else
                    {
                        k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                        if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.Log ("调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.Log ("调试");
                        }
                    }
                }
            }
        }
    }
Esempio n. 19
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data2)      //直线圆弧G03内角
    {
        float k1;
        float b1;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        float R = Vector3.Distance(motion_data2.DisplayStart, motion_data2.Center_Point);

        if (motion_data1.DisplayStart.x == motion_data1.DisplayTarget.x)       //第一条直线K1不存在
        {
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)    //第一条直线的矢量方向向上
            {
                if (motion_data2.Center_Point.y == motion_data1.DisplayTarget.y)
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                }                //怕容易出现平方中是负值,相等时作特别计算
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
                    float a = (R - Radius2) * (R - Radius2);
                    float b = Mathf.Pow(motion_data1.DisplayTarget.x - motion_data2.Center_Point.x, 2);
                    if (a - b < 0.000001f)
                    {
                        a = b;
                    }
                    motion_data1.DisplayTarget.y = Mathf.Sqrt(a - b) + motion_data2.Center_Point.y;
                    //Debug.Log ("调试");
                }
            }
            else
            {
                //"调试");
                if (motion_data2.Center_Point.y == motion_data1.DisplayTarget.y)
                {
                    //"调试");
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                }                //怕容易出现平方中是负值,相等时作特别计算
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
                    float a = (R - Radius2) * (R - Radius2);
                    float b = Mathf.Pow(motion_data1.DisplayTarget.x - motion_data2.Center_Point.x, 2);
                    if (a - b < 0.000001f)
                    {
                        a = b;
                    }
                    motion_data1.DisplayTarget.y = -Mathf.Sqrt(a - b) + motion_data2.Center_Point.y;
                    //Debug.Log ("调试");
                }
            }
        }
        else        //第一条直线K1存在
        {
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);
            b1 = Radius1 * Mathf.Sqrt(1 + k1 * k1);
            //调试过
            if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
            {            //右象限
                float a = 1 + k1 * k1;
                float b = -2 * motion_data2.Center_Point.x + 2 * k1 * (-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b1 - motion_data2.Center_Point.y);
                float c = Mathf.Pow(motion_data2.Center_Point.x, 2) + Mathf.Pow(-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y + b1 - motion_data2.Center_Point.y, 2) - (R - Radius2) * (R - Radius2);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                //Debug.Log (d + "   " + R);
                motion_data1.DisplayTarget.x = (Mathf.Sqrt(d) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y + b1;
                //Debug.Log ("调试");
            }
            else
            {            //左象限
                float a = 1 + k1 * k1;
                float b = -2 * motion_data2.Center_Point.x + 2 * k1 * (-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b1 - motion_data2.Center_Point.y);
                float c = Mathf.Pow(motion_data2.Center_Point.x, 2) + Mathf.Pow(-k1 * motion_data1.DisplayTarget.x + motion_data1.DisplayTarget.y - b1 - motion_data2.Center_Point.y, 2) - (R - Radius2) * (R - Radius2);
                float d = b * b - 4 * a * c;
                if (d < 0.000001f)
                {
                    d = 0;
                }
                motion_data1.DisplayTarget.x = (-Mathf.Sqrt(d) - b) / (2 * a);
                motion_data1.DisplayTarget.y = k1 * (motion_data1.DisplayTarget.x - motion_data2.DisplayStart.x) + motion_data1.DisplayTarget.y - b1;
                //Debug.Log ("调试");
            }
        }
    }
Esempio n. 20
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        if (motion_data2.DisplayStart.x == motion_data1.DisplayStart.x)       //第一段直线的斜率k1不存在
        {
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//		        motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x && motion_data2.DisplayTarget.y < motion_data2.DisplayStart.y)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.LogError("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.LogError("调试");                         //
                    }
                }
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//		        motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;

                if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                }
                else
                {
                    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                    if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.LogError("调试");                         //
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.LogError("调试");
                    }
                }
            }
        }
        else        //k1存在
        {
            k1 = (motion_data2.DisplayStart.y - motion_data1.DisplayStart.y) / (motion_data2.DisplayStart.x - motion_data1.DisplayStart.x);
//			if(k1 == 0)
//			{
//				if(motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
//				{
//				    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
//				    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1;
//
//					if(motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
//					{
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
//				        //Debug.LogError ("调试");
//					}
//					else
//					{
//				        k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y)/(motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2/Mathf.Sqrt(1 + k2*k2);
//				        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2*k2/Mathf.Sqrt(1 + k2*k2);
//				        //Debug.LogError ("调试");
//					}
//				}
//				else
//				{
//				    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
//				    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1;
//
//					if(motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
//					{
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
//				        //Debug.LogError ("调试");
//					}
//					else
//					{
//					    k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y)/(motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2/Mathf.Sqrt(1 + k2*k2);
//					    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2*k2/Mathf.Sqrt(1 + k2*k2);
//				        //Debug.LogError ("调试");
//					}
//				}
//			}
//			else if(k1 > 0)
//			{
//				if(motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
//				{
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1*k1/Mathf.Sqrt(1 + k1*k1);
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1/Mathf.Sqrt(1 + k1*k1);
//					//Debug.LogError ("调试");
//					if(motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
//					{
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y)/(motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
//						if(motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
//						{
//							motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2/Mathf.Sqrt(1 + k2*k2);
//							motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2*k2/Mathf.Sqrt(1 + k2*k2);
//							//"调试");
//						}
//						else
//						{
//							motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2/Mathf.Sqrt(1 + k2*k2);
//							motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2*k2/Mathf.Sqrt(1 + k2*k2);
//							//"调试");
//						}
//					}
//				}
//				else
//				{
//					motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1*k1/Mathf.Sqrt(1 + k1*k1);
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1/Mathf.Sqrt(1 + k1*k1);
//					//Debug.LogError ("调试");
//					if(motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
//					{
//						motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
//						motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
//					}
//					else
//					{
//						k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y)/(motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
//						if(motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
//						{
//							motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2/Mathf.Sqrt(1 + k2*k2);
//							motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2*k2/Mathf.Sqrt(1 + k2*k2);
//							//Debug.LogError ("调试");
//						}
//						else
//						{
//							motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2/Mathf.Sqrt(1 + k2*k2);
//							motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2*k2/Mathf.Sqrt(1 + k2*k2);
//							//"调试");
//						}
//					}
//				}
//			}
//			else//K1小于零
            {
                if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                    {
                        if (motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                            Debug.LogError("调试");                             //
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                            Debug.LogError("调试");                             //
                        }
                    }
                    else
                    {
                        k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                        if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            Debug.LogError("调试");                             //
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            Debug.LogError("调试");                             //
                        }
                    }
                }
                else
                {                //Debug.LogError ("调试");
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    //("调试");
                    if (motion_data2.DisplayStart.x == motion_data2.Center_Point.x)
                    {
                        if (motion_data2.Center_Point.y > motion_data2.DisplayStart.y)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2;
                            Debug.LogError("调试");                             //
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x;
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2;
                            Debug.LogError("调试");                             //
                        }
                    }
                    else
                    {
                        k2 = (motion_data2.Center_Point.y - motion_data2.DisplayStart.y) / (motion_data2.Center_Point.x - motion_data2.DisplayStart.x);
                        if (motion_data2.Center_Point.x > motion_data2.DisplayStart.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            Debug.LogError("调试");                             //
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            Debug.LogError("调试");                             //
                        }
                    }
                }
            }
        }
    }
Esempio n. 21
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);                                 //确保都是正值
        Radius2 = Mathf.Abs(Radius2);
        motion_data_circle.Center_Point = motion_data1.DisplayTarget; //保证圆心的坐标未改变

        //k1,k2都不存在的时候,两者的方向矢量方向相反
        if (motion_data1.DisplayStart.x == motion_data1.DisplayTarget.x && motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
        {
            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y && motion_data2.DisplayTarget.y < motion_data2.DisplayStart.x)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2;
                motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
            }
        }
        else if (motion_data1.DisplayStart.x == motion_data1.DisplayTarget.x && motion_data1.DisplayTarget.x != motion_data2.DisplayTarget.x)
        {        //k1不存在,k2存在
            k2 = (motion_data2.DisplayTarget.y - motion_data1.DisplayTarget.y) / (motion_data2.DisplayTarget.x - motion_data1.DisplayTarget.x);

            if (motion_data1.DisplayTarget.y > motion_data1.DisplayStart.y)
            {
                motion_data1.DisplayTarget.x       = motion_data1.DisplayTarget.x - Radius1;
                motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
            }
            else
            {
                motion_data1.DisplayTarget.x       = motion_data1.DisplayTarget.x + Radius1;
                motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
            }
        }
        else if (motion_data1.DisplayStart.x != motion_data1.DisplayTarget.x && motion_data1.DisplayTarget.x == motion_data2.DisplayTarget.x)
        {        //k1存在,k2不存在
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);

            if (motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
            {
                motion_data1.DisplayTarget.x       = motion_data1.DisplayTarget.x + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y       = motion_data1.DisplayTarget.y - Radius1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2;
                motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
            }
            else
            {
                motion_data1.DisplayTarget.x       = motion_data1.DisplayTarget.x - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y       = motion_data1.DisplayTarget.y + Radius1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2;
                motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                //Debug.LogError("测试");
            }            //修改过
        }
        else
        {        //k1,k2都存在
            k1 = (motion_data1.DisplayTarget.y - motion_data1.DisplayStart.y) / (motion_data1.DisplayTarget.x - motion_data1.DisplayStart.x);
            k2 = (motion_data2.DisplayTarget.y - motion_data1.DisplayTarget.y) / (motion_data2.DisplayTarget.x - motion_data1.DisplayTarget.x);
            int Left_Right_Array;
            //标志左右象限
            if (motion_data1.DisplayTarget.x > motion_data1.DisplayStart.x)
            {
                Left_Right_Array = 1;
            }
            else
            {
                Left_Right_Array = -1;
            }

            if (k1 == 0)
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Left_Right_Array;
                //Debug.Log ("调试");
                if (k2 > 0)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Left_Right_Array * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * Left_Right_Array / Mathf.Sqrt(1 + k2 * k2);
                }
                else
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * Left_Right_Array * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Left_Right_Array / Mathf.Sqrt(1 + k2 * k2);
                    //"调试");
                }
            }
            else if (k1 > 0)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 * Left_Right_Array * k1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Left_Right_Array / Mathf.Sqrt(1 + k1 * k1);

                if (k1 < k2)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Left_Right_Array * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * Left_Right_Array / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
                else
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * Left_Right_Array * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Left_Right_Array / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
            }
            else if (k1 < 0)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 * Left_Right_Array * k1 / Mathf.Sqrt(1 + k1 * k1);
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Left_Right_Array / Mathf.Sqrt(1 + k1 * k1);

                if (k1 > k2)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * Left_Right_Array * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 * Left_Right_Array / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
                else
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * Left_Right_Array * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 * Left_Right_Array / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
            }
        }
    }
Esempio n. 22
0
    public void main(ref MotionInfo motion_data1, ref MotionInfo motion_data_circle, ref MotionInfo motion_data2)
    {
        float k1;
        float k2;
        float Radius1;
        float Radius2;

        //获取半径
        if (motion_data1.D_Value == 0)
        {
            Radius1 = 0;
        }
        else
        {
            Radius1 = LoadRadiusValue.D_Value(motion_data1.D_Value);
        }

        if (motion_data2.D_Value == 0)
        {
            Radius2 = 0;
        }
        else
        {
            Radius2 = LoadRadiusValue.D_Value(motion_data2.D_Value);
        }

        Radius1 = Mathf.Abs(Radius1);         //确保都是正值
        Radius2 = Mathf.Abs(Radius2);

        if (motion_data1.Center_Point.y == motion_data1.DisplayTarget.y)       //第一段圆弧终点处半径所在直线的斜率为零
        {
            if (motion_data1.Center_Point.x < motion_data1.DisplayTarget.x)
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x && motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x + Radius2;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                    //Debug.Log ("调试");	不用测试
                }
                else if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x && motion_data2.DisplayTarget.y < motion_data2.DisplayStart.y)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius1;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    //Debug.Log ("调试");	不用测试
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
            }
            else
            {
                motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1;
//				motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x && motion_data2.DisplayTarget.y > motion_data2.DisplayStart.y)
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius2;
//					motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y;
                    //Debug.Log ("调试");	不用测试
                }
                else if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x && motion_data2.DisplayTarget.y < motion_data2.DisplayStart.y)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    //Debug.Log ("调试");不用测试
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                    //Debug.Log ("调试");
                }
            }
        }
        else
        {
            float Up_Down;
            if (motion_data1.Center_Point.y < motion_data1.DisplayTarget.y)
            {
                Up_Down = 1;
            }
            else
            {
                Up_Down = -1;
            }

            if (motion_data1.Center_Point.x == motion_data1.DisplayTarget.x)
            {
//				motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x;
                motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y + Radius1 * Up_Down;

                if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                {
                    motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * Up_Down;
                    motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                    //Debug.LogError ("调试1");
                }
                else
                {
                    k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                    if (motion_data2.DisplayStart.x < motion_data1.DisplayTarget.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        Debug.LogError("调试");
                    }
                    else
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                        //Debug.LogError ("调试");
                    }
                }
            }
            else
            {
                k1 = (motion_data2.DisplayStart.y - motion_data1.Center_Point.y) / (motion_data2.DisplayStart.x - motion_data1.Center_Point.x);

                if (motion_data1.Center_Point.x < motion_data2.DisplayStart.x)
                {
                    motion_data1.DisplayTarget.x = motion_data2.DisplayStart.x + Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data2.DisplayStart.y + Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * Up_Down;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                        if (motion_data2.DisplayStart.x < motion_data2.DisplayTarget.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.LogError ("调试");
                        }
                        else
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.LogError ("调试");
                        }
                    }
                }
                else
                {
                    motion_data1.DisplayTarget.x = motion_data1.DisplayTarget.x - Radius1 / Mathf.Sqrt(1 + k1 * k1);
                    motion_data1.DisplayTarget.y = motion_data1.DisplayTarget.y - Radius1 * k1 / Mathf.Sqrt(1 + k1 * k1);

                    if (motion_data2.DisplayStart.x == motion_data2.DisplayTarget.x)
                    {
                        motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * Up_Down;
                        motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y;
                        //Debug.LogError ("调试");
                    }
                    else
                    {
                        k2 = (motion_data2.DisplayTarget.y - motion_data2.DisplayStart.y) / (motion_data2.DisplayTarget.x - motion_data2.DisplayStart.x);
                        if (motion_data2.DisplayStart.x < motion_data2.DisplayTarget.x)
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x + Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y - Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.LogError ("调试");
                        }
                        else                        //不具有镜像特点
                        {
                            motion_data_circle.DisplayTarget.x = motion_data2.DisplayStart.x - Radius2 * k2 / Mathf.Sqrt(1 + k2 * k2);
                            motion_data_circle.DisplayTarget.y = motion_data2.DisplayStart.y + Radius2 / Mathf.Sqrt(1 + k2 * k2);
                            //Debug.LogError ("调试");
                        }
                    }
                }
            }
        }
    }