Beispiel #1
0
    }//  pt.parent.gameObject は pt.gameObject でも同じ意味のハズ

    public void MakeLineLog(int _id, int _o1, int _o2, GameObject _pa, bool _active, string _pname)
    {
        ObjectType = "Line";
        Id         = _id;
        Object1Id  = _o1;
        Object2Id  = _o2;
        Point[] OBJs = FindObjectsOfType <Point>();
        for (int i = 0; i < OBJs.Length; i++)
        {
            if (OBJs[i].Id == _o1)
            {
                Object1 = OBJs[i].gameObject;
            }
            if (OBJs[i].Id == _o2)
            {
                Object2 = OBJs[i].gameObject;
            }
        }
        parent     = _pa;
        Active     = _active;
        Show       = Util.ShowLog;
        PName      = _pname;
        Position.x = Util.LogLeft;
        Text1      = "直線 " + PName;
        Text2      = Object1.GetComponent <Point>().PointName + "-" + Object2.GetComponent <Point>().PointName;
    }
Beispiel #2
0
 private void ModulePOINT_ON_POINT()
 {        //二つの頂点を1つにする
     if (Object1 != null && Object2 != null)
     {
         Point p1 = Object1.GetComponent <Point>();
         Point p2 = Object2.GetComponent <Point>();
         if (p1 == null || p2 == null)
         {
             Active = false;
             return;
         }
         Vector3 v1    = p1.Vec;
         Vector3 v2    = p2.Vec;
         Vector3 v1New = 0.7f * v1 + 0.3f * v2;
         Vector3 v2New = 0.3f * v1 + 0.7f * v2;
         // debug
         float err = (p1.Vec - v1New).magnitude + (p2.Vec - v2New).magnitude;
         if (err > AppMgr.ConvergencyError)
         {
             AppMgr.ConvergencyCount++;
         }
         // debug
         if (!p1.Fixed)
         {
             p1.Vec = v1New;
         }
         if (!p2.Fixed)
         {
             p2.Vec = v2New;
         }
     }
     else
     {
         GameObject[] OBJs = FindObjectsOfType <GameObject>();
         for (int i = 0; i < OBJs.Length; i++)
         {
             Point PT = OBJs[i].GetComponent <Point>();
             if (PT != null)
             {
                 if (PT.Id == Object1Id)
                 {
                     Object1 = OBJs[i];
                 }
                 if (PT.Id == Object2Id)
                 {
                     Object2 = OBJs[i];
                 }
             }
         }
         if (Object1 == null || Object2 == null)
         {
             Active = false;
         }
     }
 }
 void GetOrigine()
 {
     if (RightAngle)
     {
         if (Object1 != null && Object2 != null)
         {
             Line LN1 = Object1.GetComponent <Line>();
             Line LN2 = Object2.GetComponent <Line>();
             if (LN1 == null || LN2 == null)
             {
                 Active = false;
                 return;
             }
             Point p11 = LN1.Point1.GetComponent <Point>();
             Point p12 = LN1.Point2.GetComponent <Point>();
             Point p21 = LN2.Point1.GetComponent <Point>();
             Point p22 = LN2.Point2.GetComponent <Point>();
             if (p11 == null || p12 == null || p21 == null || p22 == null)
             {
                 Active = false;
                 return;
             }
             GetIntersection(
                 p11.Vec.x, p11.Vec.y,
                 p12.Vec.x, p12.Vec.y,
                 p21.Vec.x, p21.Vec.y,
                 p22.Vec.x, p22.Vec.y);
         }
         else
         {
             GameObject[] OBJs = FindObjectsOfType <GameObject>();
             for (int i = 0; i < OBJs.Length; i++)
             {
                 Line LN = OBJs[i].GetComponent <Line>();
                 if (LN != null)
                 {
                     if (LN.Id == Object1Id)
                     {
                         Object1 = OBJs[i];
                     }
                     if (LN.Id == Object2Id)
                     {
                         Object2 = OBJs[i];
                     }
                 }
             }
             if (Object1 == null || Object2 == null)
             {
                 Active = false;
             }
         }
     }
     else
     {
         if (Object1 != null && Object2 != null && Object3 != null)
         {
             Point Point1 = Object1.GetComponent <Point>();
             Point Point2 = Object2.GetComponent <Point>();
             Point Point3 = Object3.GetComponent <Point>();
             Origine = Point2.Vec;
             UnitX   = Point1.Vec - Origine;
             UnitX.Normalize(); // 長さ1(不要か?)
             UnitY = Point3.Vec - Origine;
             UnitY.Normalize(); // 長さ1(不要か?)
         }
         else
         {
             GameObject[] OBJs = FindObjectsOfType <GameObject>();
             for (int i = 0; i < OBJs.Length; i++)
             {
                 Point PT = OBJs[i].GetComponent <Point>();
                 if (PT != null)
                 {
                     if (PT.Id == Object1Id)
                     {
                         Object1 = OBJs[i];
                     }
                     if (PT.Id == Object2Id)
                     {
                         Object2 = OBJs[i];
                     }
                     if (PT.Id == Object3Id)
                     {
                         Object3 = OBJs[i];
                     }
                 }
             }
             if (Object1 == null || Object2 == null || Object3 == null)
             {
                 Active = false;
             }
         }
     }
 }
Beispiel #4
0
    private void ModuleANGLE()
    {
        gameObject.SetActive(Active);
        if (Object1 == null || Object2 == null || Object3 == null)
        {
            GameObject[] OBJs = FindObjectsOfType <GameObject>();
            for (int i = 0; i < OBJs.Length; i++)
            {
                Point PT = OBJs[i].GetComponent <Point>();
                if (PT != null)
                {
                    if (PT.Id == Object1Id)
                    {
                        Object1 = OBJs[i];
                    }
                    if (PT.Id == Object2Id)
                    {
                        Object2 = OBJs[i];
                    }
                    if (PT.Id == Object3Id)
                    {
                        Object3 = OBJs[i];
                    }
                }
            }
            if (Object1 == null || Object2 == null || Object3 == null)
            {
                Active = false;
            }
        }
        Point PA = Object1.GetComponent <Point>();
        Point PB = Object2.GetComponent <Point>();
        Point PC = Object3.GetComponent <Point>();

        if (PA == null || PB == null || PC == null)
        {
            Active = false;
            return;
        }
        {
            float Ax = PA.Vec.x, Ay = PA.Vec.y;
            float Bx = PB.Vec.x, By = PB.Vec.y;
            float Cx = PC.Vec.x, Cy = PC.Vec.y;
            float MidABx = Ax * 0.5f + Bx * 0.5f, MidABy = Ay * 0.5f + By * 0.5f;
            float MidCBx = Cx * 0.5f + Bx * 0.5f, MidCBy = Cy * 0.5f + By * 0.5f;
            float DeclineBA = Mathf.Atan2(Ay - By, Ax - Bx);
            float DeclineBC = Mathf.Atan2(Cy - By, Cx - Bx);
            if (DeclineBC < DeclineBA - Mathf.PI)
            {
                DeclineBC += Mathf.PI * 2f;
            }
            if (DeclineBC > DeclineBA + Mathf.PI)
            {
                DeclineBC -= Mathf.PI * 2f;
            }
            float Angle      = DeclineBC - DeclineBA;
            float AngleError = (Angle - Constant) * 0.1f;
            float MaxError   = 0.02f;
            if (Angle >= 0)
            {
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            else
            {
                AngleError = (Angle + Constant) * 0.1f;
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            // debug
            float err = Mathf.Abs(AngleError);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            if (FixAngle)
            //角を固定するときは点を動かす
            {
                float   NewAx    = (Ax - MidABx) * Mathf.Cos(AngleError) - (Ay - MidABy) * Mathf.Sin(AngleError) + MidABx;
                float   NewAy    = (Ax - MidABx) * Mathf.Sin(AngleError) + (Ay - MidABy) * Mathf.Cos(AngleError) + MidABy;
                float   NewBx    = (Bx - MidABx) * Mathf.Cos(AngleError) - (By - MidABy) * Mathf.Sin(AngleError) + MidABx;
                float   NewBy    = (Bx - MidABx) * Mathf.Sin(AngleError) + (By - MidABy) * Mathf.Cos(AngleError) + MidABy;
                Vector3 newPAVec = new Vector3(NewAx, NewAy, 0f);
                Vector3 newPBVec = new Vector3(NewBx, NewBy, 0f);
                if (!PA.Fixed)
                {
                    PA.Vec = newPAVec;
                }
                if (!PB.Fixed)
                {
                    PB.Vec = newPBVec;
                }
            }
            else //角を固定しないときは表示を変える
            {
                Constant = Mathf.Abs(Angle);
            }
        }
        {
            float Ax = PA.Vec.x, Ay = PA.Vec.y;
            float Bx = PB.Vec.x, By = PB.Vec.y;
            float Cx = PC.Vec.x, Cy = PC.Vec.y;
            float MidABx = Ax * 0.5f + Bx * 0.5f, MidABy = Ay * 0.5f + By * 0.5f;
            float MidCBx = Cx * 0.5f + Bx * 0.5f, MidCBy = Cy * 0.5f + By * 0.5f;
            float DeclineBA = Mathf.Atan2(Ay - By, Ax - Bx);
            float DeclineBC = Mathf.Atan2(Cy - By, Cx - Bx);
            if (DeclineBC < DeclineBA - Mathf.PI)
            {
                DeclineBC += Mathf.PI * 2f;
            }
            if (DeclineBC > DeclineBA + Mathf.PI)
            {
                DeclineBC -= Mathf.PI * 2f;
            }
            float Angle      = DeclineBC - DeclineBA;
            float AngleError = (Angle - Constant) * 0.1f;
            float MaxError   = 0.02f;
            if (Angle >= 0)
            {
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            else
            {
                AngleError = (Angle + Constant) * 0.1f;
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            // debug
            float err = Mathf.Abs(AngleError);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            if (FixAngle)
            {
                float   NewCx    = (Cx - MidCBx) * Mathf.Cos(-AngleError) - (Cy - MidCBy) * Mathf.Sin(-AngleError) + MidCBx;
                float   NewCy    = (Cx - MidCBx) * Mathf.Sin(-AngleError) + (Cy - MidCBy) * Mathf.Cos(-AngleError) + MidCBy;
                float   NewBx    = (Bx - MidCBx) * Mathf.Cos(-AngleError) - (By - MidCBy) * Mathf.Sin(-AngleError) + MidCBx;
                float   NewBy    = (Bx - MidCBx) * Mathf.Sin(-AngleError) + (By - MidCBy) * Mathf.Cos(-AngleError) + MidCBy;
                Vector3 newPBVec = new Vector3(NewBx, NewBy, 0f);
                Vector3 newPCVec = new Vector3(NewCx, NewCy, 0f);
                if (!PB.Fixed)
                {
                    PB.Vec = newPBVec;
                }
                if (!PC.Fixed)
                {
                    PC.Vec = newPCVec;
                }
            }
            else
            {
                Constant = Mathf.Abs(Angle);
            }
        }
    }
Beispiel #5
0
 private void ModuleCIRCLE_TANGENT_CIRCLE()
 {//円を円に(外)接させる
     //Object1Id : 円1
     //Object2Id : 円2
     // 円と中心を探す
     gameObject.SetActive(Active);
     if (Object1 != null && Object2 != null)
     {
         Circle CI1 = Object1.GetComponent <Circle>();
         Circle CI2 = Object2.GetComponent <Circle>();
         if (CI1 == null || CI2 == null)
         {
             Active = false;
             return;
         }
         Point p11 = CI1.CenterPoint.GetComponent <Point>();
         Point p21 = CI2.CenterPoint.GetComponent <Point>();
         if (p11 == null || p21 == null)
         {
             Active = false;
             return;
         }
         Vector3 c1c    = p11.Vec;
         float   c1r    = CI1.Radius;
         Vector3 c2c    = p21.Vec;
         float   c2r    = CI2.Radius;
         Vector3 DVec12 = c2c - c1c;
         float   normD  = DVec12.magnitude;
         DVec12.Normalize();
         Vector3 DVec21   = -1f * DVec12;
         float   DeltaIn  = normD - Mathf.Abs(c1r - c2r);
         float   DeltaOut = normD - (c1r + c2r);
         float   Delta    = 0f;
         if (Mathf.Abs(DeltaIn) > Mathf.Abs(DeltaOut))
         {// 外接していると思われる
             Delta = DeltaOut * 0.125f;
             // debug
             float err = Mathf.Abs(Delta);
             if (err > AppMgr.ConvergencyError)
             {
                 AppMgr.ConvergencyCount++;
             }
             // debug
             //円1の中心を動かす
             if (!p11.Fixed)
             {
                 p11.Vec += Delta * DVec12;
             }
             //円2の中心を動かす
             if (!p21.Fixed)
             {
                 p21.Vec += Delta * DVec21;
             }
             //円1の半径を調整する
             CI1.Radius += Delta;
             //円2の半径を調整する
             CI2.Radius += Delta;
         }
         else
         {//内接していると思われる
             //Debug.Log("inscribed");
             bool C1out = false;
             if (c1r < c2r)
             {//C2が外側だと思われる
                 C1out = false;
             }
             else
             {
                 C1out = true;
             }
             Delta = DeltaIn * 0.125f;
             // debug
             float err = Mathf.Abs(Delta);
             if (err > AppMgr.ConvergencyError)
             {
                 AppMgr.ConvergencyCount++;
             }
             // debug
             //円1の中心を動かす
             if (!p11.Fixed)
             {
                 p11.Vec += Delta * DVec12;
             }
             //円2の中心を動かす
             if (!p21.Fixed)
             {
                 p21.Vec += Delta * DVec21;
             }
             //円1の半径を調整する
             if (C1out)
             {
                 CI1.Radius += Delta;
             }
             else
             {
                 CI1.Radius -= Delta;
             }
             //円2の半径を調整する
             if (C1out)
             {
                 CI2.Radius -= Delta;
             }
             else
             {
                 CI2.Radius += Delta;
             }
         }
     }
     else
     {
         GameObject[] OBJs = FindObjectsOfType <GameObject>();
         for (int i = 0; i < OBJs.Length; i++)
         {
             Circle CI = OBJs[i].GetComponent <Circle>();
             if (CI != null)
             {
                 if (CI.Id == Object1Id)
                 {
                     Object1 = OBJs[i];
                 }
                 if (CI.Id == Object2Id)
                 {
                     Object2 = OBJs[i];
                 }
             }
         }
         if (Object1 == null || Object2 == null)
         {
             Active = false;
         }
     }
     return;
 }
Beispiel #6
0
 private void ModuleCIRCLE_TANGENT_LINE()
 {//円を直線に接させる
     //Object1Id : 円:
     //Object2Id : 直線
     gameObject.SetActive(Active);
     if (Object1 != null && Object2 != null)
     {
         Circle CI1 = Object1.GetComponent <Circle>();
         Line   LN2 = Object2.GetComponent <Line>();
         if (CI1 == null || LN2 == null)
         {
             Active = false;
             return;
         }
         Point p11 = CI1.CenterPoint.GetComponent <Point>();
         Point p21 = LN2.Point1.GetComponent <Point>();
         Point p22 = LN2.Point2.GetComponent <Point>();
         if (p11 == null || p21 == null || p22 == null)
         {
             Active = false;
             return;
         }
         float   Radius = CI1.Radius;
         Vector3 DVec   = Rotate90(p22.Vec - p21.Vec);
         DVec.Normalize();
         Vector3 PVec     = p11.Vec - p21.Vec;
         float   Distance = Vector3.Dot(DVec, PVec);
         if (Distance < 0)
         {
             DVec     *= -1f;
             Distance *= -1f;
         }
         float Delta = (Distance - Radius) * 0.16f;
         // debug
         float err = Mathf.Abs(Delta);
         if (err > AppMgr.ConvergencyError)
         {
             AppMgr.ConvergencyCount++;
         }
         // debug
         // 円の中心を直線に近づける
         if (!p11.Fixed)
         {
             p11.Vec -= Delta * DVec;
         }
         //円の半径を適切に変化させる
         CI1.Radius += Delta;
         // 直線を円に近づける
         if (!p21.Fixed)
         {
             p21.Vec += Delta * DVec;
         }
         if (!p22.Fixed)
         {
             p22.Vec += Delta * DVec;
         }
     }
     else
     {
         GameObject[] OBJs = FindObjectsOfType <GameObject>();
         for (int i = 0; i < OBJs.Length; i++)
         {
             Circle CI = OBJs[i].GetComponent <Circle>();
             if (CI != null)
             {
                 if (CI.Id == Object1Id)
                 {
                     Object1 = OBJs[i];
                 }
             }
             Line LN = OBJs[i].GetComponent <Line>();
             if (LN != null)
             {
                 if (LN.Id == Object2Id)
                 {
                     Object2 = OBJs[i];
                 }
             }
         }
         if (Object1 == null || Object2 == null)
         {
             Active = false;
         }
     }
     return;
 }
Beispiel #7
0
 private void ModuleLINES_PARALLEL()
 {//直線を平行にする
     gameObject.SetActive(Active);
     if (Object1 != null && Object2 != null)
     {
         Line LN1 = Object1.GetComponent <Line>();
         Line LN2 = Object2.GetComponent <Line>();
         if (LN1 == null || LN2 == null)
         {
             Active = false;
             return;
         }
         Point p11 = LN1.Point1.GetComponent <Point>();
         Point p12 = LN1.Point2.GetComponent <Point>();
         Point p21 = LN2.Point1.GetComponent <Point>();
         Point p22 = LN2.Point2.GetComponent <Point>();
         if (p11 == null || p12 == null || p21 == null || p22 == null)
         {
             Active = false;
             return;
         }
         float x11    = p11.Vec.x;
         float y11    = p11.Vec.y;
         float x12    = p12.Vec.x;
         float y12    = p12.Vec.y;
         float x21    = p21.Vec.x;
         float y21    = p21.Vec.y;
         float x22    = p22.Vec.x;
         float y22    = p22.Vec.y;
         float theta1 = Mathf.Atan2(y12 - y11, x12 - x11);
         float theta2 = Mathf.Atan2(y22 - y21, x22 - x21);
         float Delta  = theta2 - theta1;
         if (Delta > Mathf.PI * 3 / 2)
         {
             Delta -= Mathf.PI * 2;
         }
         else if (Delta > Mathf.PI / 2)
         {
             Delta -= Mathf.PI;
         }
         else if (Delta > -Mathf.PI / 2)
         {
             Delta += 0;
         }
         else if (Delta >= -Mathf.PI * 3 / 2)
         {
             Delta += Mathf.PI;
         }
         else
         {
             Delta += Mathf.PI * 2;
         }
         Delta *= 0.125f;
         float CosDelta = Mathf.Cos(Delta);
         float SinDelta = Mathf.Sin(Delta);
         float x1c      = (x11 + x12) * 0.5f;
         float y1c      = (y11 + y12) * 0.5f;
         float x2c      = (x21 + x22) * 0.5f;
         float y2c      = (y21 + y22) * 0.5f;
         // debug
         float err = Mathf.Abs(SinDelta);
         if (err > AppMgr.ConvergencyError)
         {
             AppMgr.ConvergencyCount++;
         }
         // debug
         Vector3 NewVec = Vector3.zero;
         NewVec.x = (x11 - x1c) * CosDelta - (y11 - y1c) * SinDelta + x1c;
         NewVec.y = +(x11 - x1c) * SinDelta + (y11 - y1c) * CosDelta + y1c;
         if (!p11.Fixed)
         {
             p11.Vec = NewVec;
         }
         NewVec.x = (x12 - x1c) * CosDelta - (y12 - y1c) * SinDelta + x1c;
         NewVec.y = +(x12 - x1c) * SinDelta + (y12 - y1c) * CosDelta + y1c;
         if (!p12.Fixed)
         {
             p12.Vec = NewVec;
         }
         NewVec.x = (x21 - x2c) * CosDelta + (y21 - y2c) * SinDelta + x2c;
         NewVec.y = -(x21 - x2c) * SinDelta + (y21 - y2c) * CosDelta + y2c;
         if (!p21.Fixed)
         {
             p21.Vec = NewVec;
         }
         NewVec.x = (x22 - x2c) * CosDelta + (y22 - y2c) * SinDelta + x2c;
         NewVec.y = -(x22 - x2c) * SinDelta + (y22 - y2c) * CosDelta + y2c;
         if (!p22.Fixed)
         {
             p22.Vec = NewVec;
         }
     }
     else
     {
         GameObject[] OBJs = FindObjectsOfType <GameObject>();
         for (int i = 0; i < OBJs.Length; i++)
         {
             Line LN = OBJs[i].GetComponent <Line>();
             if (LN != null)
             {
                 if (LN.Id == Object1Id)
                 {
                     Object1 = OBJs[i];
                 }
                 if (LN.Id == Object2Id)
                 {
                     Object2 = OBJs[i];
                 }
             }
         }
         if (Object1 == null || Object2 == null)
         {
             Active = false;
         }
     }
     return;
 }
Beispiel #8
0
    private void ModuleLINES_ISOMETRY()
    {
        gameObject.SetActive(Active);
        if (Object1 != null && Object2 != null)
        {
            Line LN1 = Object1.GetComponent <Line>();
            Line LN2 = Object2.GetComponent <Line>();
            if (LN1 == null || LN2 == null)
            {
                Active = false;
                return;
            }
            Point p11 = LN1.Point1.GetComponent <Point>();
            Point p12 = LN1.Point2.GetComponent <Point>();
            Point p21 = LN2.Point1.GetComponent <Point>();
            Point p22 = LN2.Point2.GetComponent <Point>();
            if (p11 == null || p12 == null || p21 == null || p22 == null)
            {
                Active = false;
                return;
            }
            Vector3 VecA, VecB;
            float   NormA, NormB, Delta;

            VecA  = p12.Vec - p11.Vec;
            VecB  = p22.Vec - p21.Vec;
            NormA = VecA.magnitude;
            NormB = VecB.magnitude;
            VecA.Normalize();
            VecB.Normalize();
            //Delta = (NormB - NormA) * 0.125f;//等長
            Delta = (NormB * Ratio1 - NormA * Ratio2) / (Ratio1 + Ratio2) * 0.25f;//Ratioの値によって変わる
            // debug
            float err = Mathf.Abs(Delta);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            //  線分の長さを等しくする
            if (!p11.Fixed)
            {
                p11.Vec -= Delta * VecA;
            }
            if (!p21.Fixed)
            {
                p21.Vec += Delta * VecB;
            }
            if (!p12.Fixed)
            {
                p12.Vec += Delta * VecA;
            }
            if (!p22.Fixed)
            {
                p22.Vec -= Delta * VecB;
            }
        }
        else
        {
            GameObject[] OBJs = FindObjectsOfType <GameObject>();
            for (int i = 0; i < OBJs.Length; i++)
            {
                Line LN = OBJs[i].GetComponent <Line>();
                if (LN != null)
                {
                    if (LN.Id == Object1Id)
                    {
                        Object1 = OBJs[i];
                    }
                    if (LN.Id == Object2Id)
                    {
                        Object2 = OBJs[i];
                    }
                }
            }
            if (Object1 == null || Object2 == null)
            {
                Active = false;
            }
        }
    }
Beispiel #9
0
    private void ModulePOINT_ON_CIRCLE()
    {        // 点を円の上に載せる
        Point  p1 = null, p21 = null;
        Circle c2 = null;

        if (parent != null)
        {
            parent.SetActive(Active);
        }
        if (Object1 != null && Object2 != null)
        {
            p1  = Object1.GetComponent <Point>();
            c2  = Object2.GetComponent <Circle>();
            p21 = c2.CenterPoint.GetComponent <Point>();
            if (p1 == null || c2 == null || p21 == null)
            {
                Active = false;
                return;
            }
            float dist   = Vector3.Distance(p21.Vec, p1.Vec);
            float rad    = c2.Radius;
            float delta  = (dist - rad) * 0.25f;
            float radNew = rad + delta;
            c2.Radius = radNew;
            Vector3 v2 = p1.Vec - p21.Vec;
            v2.Normalize();
            // debug
            float err = Mathf.Abs(delta);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            if (!p1.Fixed)
            {
                p1.Vec = p1.Vec - delta * v2;
            }
            if (!p21.Fixed)
            {
                p21.Vec = p21.Vec + delta * v2;
            }
        }
        else
        {
            GameObject[] OBJs = FindObjectsOfType <GameObject>();
            for (int i = 0; i < OBJs.Length; i++)
            {
                Point PT = OBJs[i].GetComponent <Point>();
                if (PT != null)
                {
                    if (PT.Id == Object1Id)
                    {
                        Object1 = OBJs[i];
                    }
                }
                Circle CI = OBJs[i].GetComponent <Circle>();
                if (CI != null)
                {
                    if (CI.Id == Object2Id)
                    {
                        Object2 = OBJs[i];
                    }
                }
            }
            if (Object1 == null || Object2 == null)
            {
                Active = false;
            }
        }
    }
Beispiel #10
0
 private void ModulePOINT_ON_LINE()
 {
     // 点を直線の上に載せる。
     if (parent != null)
     {
         parent.SetActive(Active);
     }
     if (Object1 != null && Object2 != null)
     {
         Point p1 = Object1.GetComponent <Point>();
         Line  l2 = Object2.GetComponent <Line>();
         if (p1 == null || l2 == null)
         {
             Active = false;
             return;
         }
         Point p21 = l2.Point1.GetComponent <Point>();
         Point p22 = l2.Point2.GetComponent <Point>();
         if (p21 == null || p22 == null)
         {
             Active = false;
             return;
         }
         float   Distance;
         Vector3 DVec, PVec;
         DVec = Rotate90(p22.Vec - p21.Vec);
         DVec.Normalize();
         PVec     = p1.Vec - p21.Vec;
         Distance = Vector3.Dot(DVec, PVec);
         // debug
         float err = Mathf.Abs(Distance) * 0.25f;
         if (err > AppMgr.ConvergencyError)
         {
             AppMgr.ConvergencyCount++;
         }
         // debug
         if (!p1.Fixed)
         {// 点を直線に近づける
             p1.Vec -= (Distance * 0.25f) * DVec;
         }
         if (!p21.Fixed)
         { //直線を点に近づける
             p21.Vec += (Distance * 0.25f) * DVec;
         }
         if (!p22.Fixed)
         { //直線を点に近づける
             p22.Vec += (Distance * 0.25f) * DVec;
         }
     }
     else
     {
         GameObject[] OBJs = FindObjectsOfType <GameObject>();
         for (int i = 0; i < OBJs.Length; i++)
         {
             Point PT = OBJs[i].GetComponent <Point>();
             if (PT != null)
             {
                 if (PT.Id == Object1Id)
                 {
                     Object1 = OBJs[i];
                 }
             }
             Line LN = OBJs[i].GetComponent <Line>();
             if (LN != null)
             {
                 if (LN.Id == Object2Id)
                 {
                     Object2 = OBJs[i];
                 }
             }
         }
         if (Object1 == null || Object2 == null)
         {
             Active = false;
         }
     }
 }
Beispiel #11
0
    private void ModuleBISECTOR()
    {
        gameObject.SetActive(Active);
        if (Object1 == null || Object2 == null)
        {
            GameObject[] OBJs = FindObjectsOfType <GameObject>();
            for (int i = 0; i < OBJs.Length; i++)
            {
                Module MD = OBJs[i].GetComponent <Module>();
                if (MD != null)
                {
                    if (MD.Id == Object1Id)
                    {
                        Object1 = OBJs[i];
                    }
                    if (MD.Id == Object2Id)
                    {
                        Object2 = OBJs[i];
                    }
                }
            }
            if (Object1 == null || Object2 == null)
            {
                Active = false;
            }
        }
        Module md1  = Object1.GetComponent <Module>();
        Module md2  = Object2.GetComponent <Module>();
        Point  M1PA = md1.Object1.GetComponent <Point>();
        Point  M1PB = md1.Object2.GetComponent <Point>();
        Point  M1PC = md1.Object3.GetComponent <Point>();
        Point  M2PA = md2.Object1.GetComponent <Point>();
        Point  M2PB = md2.Object2.GetComponent <Point>();
        Point  M2PC = md2.Object3.GetComponent <Point>();

        if (M1PA == null || M1PB == null || M1PC == null || M2PA == null || M2PB == null || M2PC == null)
        {
            Active = false;
            return;
        }
        float M2PAx = M2PA.Vec.x, M2PAy = M2PA.Vec.y;
        float M2PBx = M2PB.Vec.x, M2PBy = M2PB.Vec.y;
        float M2PCx = M2PC.Vec.x, M2PCy = M2PC.Vec.y;
        float M2MidABx = M2PAx * 0.5f + M2PBx * 0.5f, M2MidABy = M2PAy * 0.5f + M2PBy * 0.5f;
        float M2MidCBx = M2PCx * 0.5f + M2PBx * 0.5f, M2MidCBy = M2PCy * 0.5f + M2PBy * 0.5f;
        float M2DeclineBA = Mathf.Atan2(M2PAy - M2PBy, M2PAx - M2PBx);
        float M2DeclineBC = Mathf.Atan2(M2PCy - M2PBy, M2PCx - M2PBx);

        if (M2DeclineBC < M2DeclineBA - Mathf.PI)
        {
            M2DeclineBC += Mathf.PI * 2f;
        }
        if (M2DeclineBC > M2DeclineBA + Mathf.PI)
        {
            M2DeclineBC -= Mathf.PI * 2f;
        }
        float M2Angle  = M2DeclineBC - M2DeclineBA;
        float Constant = Mathf.Abs(M2Angle);
        {
            float Ax = M1PA.Vec.x, Ay = M1PA.Vec.y;
            float Bx = M1PB.Vec.x, By = M1PB.Vec.y;
            float Cx = M1PC.Vec.x, Cy = M1PC.Vec.y;
            float MidABx = Ax * 0.5f + Bx * 0.5f, MidABy = Ay * 0.5f + By * 0.5f;
            float MidCBx = Cx * 0.5f + Bx * 0.5f, MidCBy = Cy * 0.5f + By * 0.5f;
            float DeclineBA = Mathf.Atan2(Ay - By, Ax - Bx);
            float DeclineBC = Mathf.Atan2(Cy - By, Cx - Bx);
            if (DeclineBC < DeclineBA - Mathf.PI)
            {
                DeclineBC += Mathf.PI * 2f;
            }
            if (DeclineBC > DeclineBA + Mathf.PI)
            {
                DeclineBC -= Mathf.PI * 2f;
            }
            float Angle      = DeclineBC - DeclineBA;
            float AngleError = (Angle - Constant) * 0.1f;
            float MaxError   = 0.02f;
            if (Angle >= 0)
            {
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            else
            {
                AngleError = (Angle + Constant) * 0.1f;
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            // debug
            float err = Mathf.Abs(AngleError);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            float   NewAx    = (Ax - MidABx) * Mathf.Cos(AngleError) - (Ay - MidABy) * Mathf.Sin(AngleError) + MidABx;
            float   NewAy    = (Ax - MidABx) * Mathf.Sin(AngleError) + (Ay - MidABy) * Mathf.Cos(AngleError) + MidABy;
            float   NewBx    = (Bx - MidABx) * Mathf.Cos(AngleError) - (By - MidABy) * Mathf.Sin(AngleError) + MidABx;
            float   NewBy    = (Bx - MidABx) * Mathf.Sin(AngleError) + (By - MidABy) * Mathf.Cos(AngleError) + MidABy;
            Vector3 newPAVec = new Vector3(NewAx, NewAy, 0f);
            Vector3 newPBVec = new Vector3(NewBx, NewBy, 0f);
            if (!M1PA.Fixed && !FixAngle)
            {
                M1PA.Vec = newPAVec;
            }
            if (!M1PB.Fixed && !FixAngle)
            {
                M1PB.Vec = newPBVec;
            }
        }
        {
            float Ax = M1PA.Vec.x, Ay = M1PA.Vec.y;
            float Bx = M1PB.Vec.x, By = M1PB.Vec.y;
            float Cx = M1PC.Vec.x, Cy = M1PC.Vec.y;
            float MidABx = Ax * 0.5f + Bx * 0.5f, MidABy = Ay * 0.5f + By * 0.5f;
            float MidCBx = Cx * 0.5f + Bx * 0.5f, MidCBy = Cy * 0.5f + By * 0.5f;
            float DeclineBA = Mathf.Atan2(Ay - By, Ax - Bx);
            float DeclineBC = Mathf.Atan2(Cy - By, Cx - Bx);
            if (DeclineBC < DeclineBA - Mathf.PI)
            {
                DeclineBC += Mathf.PI * 2f;
            }
            if (DeclineBC > DeclineBA + Mathf.PI)
            {
                DeclineBC -= Mathf.PI * 2f;
            }
            float Angle      = DeclineBC - DeclineBA;
            float AngleError = (Angle - Constant) * 0.1f;
            float MaxError   = 0.02f;
            if (Angle >= 0)
            {
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            else
            {
                AngleError = (Angle + Constant) * 0.1f;
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            // debug
            float err = Mathf.Abs(AngleError);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            float   NewCx    = (Cx - MidCBx) * Mathf.Cos(-AngleError) - (Cy - MidCBy) * Mathf.Sin(-AngleError) + MidCBx;
            float   NewCy    = (Cx - MidCBx) * Mathf.Sin(-AngleError) + (Cy - MidCBy) * Mathf.Cos(-AngleError) + MidCBy;
            float   NewBx    = (Bx - MidCBx) * Mathf.Cos(-AngleError) - (By - MidCBy) * Mathf.Sin(-AngleError) + MidCBx;
            float   NewBy    = (Bx - MidCBx) * Mathf.Sin(-AngleError) + (By - MidCBy) * Mathf.Cos(-AngleError) + MidCBy;
            Vector3 newPBVec = new Vector3(NewBx, NewBy, 0f);
            Vector3 newPCVec = new Vector3(NewCx, NewCy, 0f);
            if (!M1PB.Fixed && !FixAngle)
            {
                M1PB.Vec = newPBVec;
            }
            if (!M1PC.Fixed && !FixAngle)
            {
                M1PC.Vec = newPCVec;
            }
        }
        float M1PAx = M1PA.Vec.x, M1PAy = M1PA.Vec.y;
        float M1PBx = M1PB.Vec.x, M1PBy = M1PB.Vec.y;
        float M1PCx = M1PC.Vec.x, M1PCy = M1PC.Vec.y;
        float M1MidABx = M1PAx * 0.5f + M1PBx * 0.5f, M1MidABy = M1PAy * 0.5f + M1PBy * 0.5f;
        float M1MidCBx = M1PCx * 0.5f + M1PBx * 0.5f, M1MidCBy = M1PCy * 0.5f + M1PBy * 0.5f;
        float M1DeclineBA = Mathf.Atan2(M1PAy - M1PBy, M1PAx - M1PBx);
        float M1DeclineBC = Mathf.Atan2(M1PCy - M1PBy, M1PCx - M1PBx);

        if (M1DeclineBC < M1DeclineBA - Mathf.PI)
        {
            M1DeclineBC += Mathf.PI * 2f;
        }
        if (M1DeclineBC > M1DeclineBA + Mathf.PI)
        {
            M1DeclineBC -= Mathf.PI * 2f;
        }
        float M1Angle = M1DeclineBC - M1DeclineBA;

        Constant = Mathf.Abs(M1Angle);
        {
            float Ax = M2PA.Vec.x, Ay = M2PA.Vec.y;
            float Bx = M2PB.Vec.x, By = M2PB.Vec.y;
            float Cx = M2PC.Vec.x, Cy = M2PC.Vec.y;
            float MidABx = Ax * 0.5f + Bx * 0.5f, MidABy = Ay * 0.5f + By * 0.5f;
            float MidCBx = Cx * 0.5f + Bx * 0.5f, MidCBy = Cy * 0.5f + By * 0.5f;
            float DeclineBA = Mathf.Atan2(Ay - By, Ax - Bx);
            float DeclineBC = Mathf.Atan2(Cy - By, Cx - Bx);
            if (DeclineBC < DeclineBA - Mathf.PI)
            {
                DeclineBC += Mathf.PI * 2f;
            }
            if (DeclineBC > DeclineBA + Mathf.PI)
            {
                DeclineBC -= Mathf.PI * 2f;
            }
            float Angle      = DeclineBC - DeclineBA;
            float AngleError = (Angle - Constant) * 0.1f;
            float MaxError   = 0.02f;
            if (Angle >= 0)
            {
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            else
            {
                AngleError = (Angle + Constant) * 0.1f;
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            // debug
            float err = Mathf.Abs(AngleError);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            float   NewAx    = (Ax - MidABx) * Mathf.Cos(AngleError) - (Ay - MidABy) * Mathf.Sin(AngleError) + MidABx;
            float   NewAy    = (Ax - MidABx) * Mathf.Sin(AngleError) + (Ay - MidABy) * Mathf.Cos(AngleError) + MidABy;
            float   NewBx    = (Bx - MidABx) * Mathf.Cos(AngleError) - (By - MidABy) * Mathf.Sin(AngleError) + MidABx;
            float   NewBy    = (Bx - MidABx) * Mathf.Sin(AngleError) + (By - MidABy) * Mathf.Cos(AngleError) + MidABy;
            Vector3 newPAVec = new Vector3(NewAx, NewAy, 0f);
            Vector3 newPBVec = new Vector3(NewBx, NewBy, 0f);
            if (!M2PA.Fixed && !FixAngle)
            {
                M2PA.Vec = newPAVec;
            }
            if (!M2PB.Fixed && !FixAngle)
            {
                M2PB.Vec = newPBVec;
            }
        }
        {
            float Ax = M2PA.Vec.x, Ay = M2PA.Vec.y;
            float Bx = M2PB.Vec.x, By = M2PB.Vec.y;
            float Cx = M2PC.Vec.x, Cy = M2PC.Vec.y;
            float MidABx = Ax * 0.5f + Bx * 0.5f, MidABy = Ay * 0.5f + By * 0.5f;
            float MidCBx = Cx * 0.5f + Bx * 0.5f, MidCBy = Cy * 0.5f + By * 0.5f;
            float DeclineBA = Mathf.Atan2(Ay - By, Ax - Bx);
            float DeclineBC = Mathf.Atan2(Cy - By, Cx - Bx);
            if (DeclineBC < DeclineBA - Mathf.PI)
            {
                DeclineBC += Mathf.PI * 2f;
            }
            if (DeclineBC > DeclineBA + Mathf.PI)
            {
                DeclineBC -= Mathf.PI * 2f;
            }
            float Angle      = DeclineBC - DeclineBA;
            float AngleError = (Angle - Constant) * 0.1f;
            float MaxError   = 0.02f;
            if (Angle >= 0)
            {
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            else
            {
                AngleError = (Angle + Constant) * 0.1f;
                if (AngleError > MaxError)
                {
                    AngleError = MaxError;
                }
                if (AngleError < -MaxError)
                {
                    AngleError = -MaxError;
                }
            }
            // debug
            float err = Mathf.Abs(AngleError);
            if (err > AppMgr.ConvergencyError)
            {
                AppMgr.ConvergencyCount++;
            }
            // debug
            float   NewCx    = (Cx - MidCBx) * Mathf.Cos(-AngleError) - (Cy - MidCBy) * Mathf.Sin(-AngleError) + MidCBx;
            float   NewCy    = (Cx - MidCBx) * Mathf.Sin(-AngleError) + (Cy - MidCBy) * Mathf.Cos(-AngleError) + MidCBy;
            float   NewBx    = (Bx - MidCBx) * Mathf.Cos(-AngleError) - (By - MidCBy) * Mathf.Sin(-AngleError) + MidCBx;
            float   NewBy    = (Bx - MidCBx) * Mathf.Sin(-AngleError) + (By - MidCBy) * Mathf.Cos(-AngleError) + MidCBy;
            Vector3 newPBVec = new Vector3(NewBx, NewBy, 0f);
            Vector3 newPCVec = new Vector3(NewCx, NewCy, 0f);
            if (!M2PB.Fixed && !FixAngle)
            {
                M2PB.Vec = newPBVec;
            }
            if (!M2PC.Fixed && !FixAngle)
            {
                M2PC.Vec = newPCVec;
            }
        }
    }
Beispiel #12
0
 private void Update()
 {
     //Debug.Log("Log of " + ObjectType+":"+ Screen.height);
     if (ObjectType == "Point")
     {
         PName = parent.GetComponent <Point>().PointName;
         Fixed = parent.GetComponent <Point>().Fixed;
         if (AppMgr.Japanese == 1)
         {
             Text1 = "点 " + PName;
             if (Fixed)
             {
                 Text1 += "(固定)";
             }
         }
         else
         {
             Text1 = "Point " + PName;
             if (Fixed)
             {
                 Text1 += "(Fixed)";
             }
         }
         Text2    = "(" + Mathf.Round(Vec.x * 1000f) / 1000f + "," + Mathf.Round(Vec.y * 1000f) / 1000f + ")";
         Selected = parent.GetComponent <Point>().Selected;
         if (Selected)
         {
             GetComponent <MeshRenderer>().material = PointSLogMaterial;
         }
         else
         {
             GetComponent <MeshRenderer>().material = PointLogMaterial;
         }
     }
     else if (ObjectType == "Line")
     {
         if (Object1 == null || Object2 == null)
         {
             GameObject[] OBJs = FindObjectsOfType <GameObject>();
             for (int i = 0; i < OBJs.Length; i++)
             {
                 Point PT = OBJs[i].GetComponent <Point>();
                 if (PT != null)
                 {
                     if (PT.Id == parent.GetComponent <Line>().Point1Id)
                     {
                         Object1 = OBJs[i];
                     }
                     if (PT.Id == parent.GetComponent <Line>().Point2Id)
                     {
                         Object2 = OBJs[i];
                     }
                 }
             }
         }
         if (AppMgr.Japanese == 1)
         {
             Text1 = "直線 " + PName;
         }
         else
         {
             Text1 = "Line " + PName;
         }
         Text2    = Object1.GetComponent <Point>().PointName + "-" + Object2.GetComponent <Point>().PointName;
         Selected = parent.GetComponent <Line>().Selected;
         if (Selected)
         {
             GetComponent <MeshRenderer>().material = LineSLogMaterial;
         }
         else
         {
             GetComponent <MeshRenderer>().material = LineLogMaterial;
         }
     }
     else if (ObjectType == "Circle")
     {
         if (Object1 == null)
         {
             GameObject[] OBJs = FindObjectsOfType <GameObject>();
             for (int i = 0; i < OBJs.Length; i++)
             {
                 Point PT = OBJs[i].GetComponent <Point>();
                 if (PT != null)
                 {
                     if (PT.Id == parent.GetComponent <Circle>().CenterPointId)
                     {
                         Object1 = OBJs[i];
                     }
                 }
             }
         }
         Radius = parent.GetComponent <Circle>().Radius;// Circle.csで実施
         if (AppMgr.Japanese == 1)
         {
             Text1 = "円 " + PName;
             Text2 = "中心" + Object1.GetComponent <Point>().PointName + ":半径" + Mathf.Round(Radius * 1000f) / 1000f;
         }
         else
         {
             Text1 = "Circle " + PName;
             Text2 = "Center " + Object1.GetComponent <Point>().PointName + ":Radius " + Mathf.Round(Radius * 1000f) / 1000f;
         }
         Selected = parent.GetComponent <Circle>().Selected;
         if (Selected)
         {
             GetComponent <MeshRenderer>().material = CircleSLogMaterial;
         }
         else
         {
             GetComponent <MeshRenderer>().material = CircleLogMaterial;
         }
     }
     else if (ObjectType == "Module")
     {
         if (Object1 == null || Object2 == null)
         {
             FindObjects4Module();
         }
         if (PName == "点 - 点")
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = GetPNameByParentObject(Object1) + "と" + GetPNameByParentObject(Object2) + "を重ねる";
             }
             else
             {
                 Text1 = "Point on point";
                 Text2 = "" + GetPNameByParentObject(Object1) + " = " + GetPNameByParentObject(Object2) + "";
             }
         }
         else if (PName == "点 - 直線")
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = GetPNameByParentObject(Object1) + "は直線" + GetPNameByParentObject(Object2) + "上";
             }
             else
             {
                 Text1 = "Point on Line";
                 Text2 = GetPNameByParentObject(Object1) + " is on " + GetPNameByParentObject(Object2) + "";
             }
         }
         else if (PName == "点 - 円")
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = GetPNameByParentObject(Object1) + "は円" + GetPNameByParentObject(Object2) + "上";
             }
             else
             {
                 Text1 = "Point on CIrcle";
                 Text2 = GetPNameByParentObject(Object1) + " is on " + GetPNameByParentObject(Object2) + "";
             }
         }
         else if (PName == "等長")
         {
             if (AppMgr.Japanese == 1)
             {
                 if (Ratio1 == Ratio2)
                 {
                     Text1 = "" + PName;
                     Text2 = GetPNameByParentObject(Object1) + "と" + GetPNameByParentObject(Object2) + "は等長";
                 }
                 else
                 {
                     Text1 = "作図 : 線分比(" + Mathf.RoundToInt(Ratio1) + "," + Mathf.RoundToInt(Ratio2) + ")";
                     Text2 = GetPNameByParentObject(Object1) + "と" + GetPNameByParentObject(Object2);
                 }
             }
             else
             {
                 if (Ratio1 == Ratio2)
                 {
                     Text1 = "Isometry";
                     Text2 = GetPNameByParentObject(Object1) + " , " + GetPNameByParentObject(Object2) + " are isometry";
                 }
                 else
                 {
                     Text1 = "Segments in Ratio(" + Mathf.RoundToInt(Ratio1) + ":" + Mathf.RoundToInt(Ratio2) + ")";
                     Text2 = GetPNameByParentObject(Object1) + " , " + GetPNameByParentObject(Object2);
                 }
             }
         }
         else if (PName == "垂直")
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = GetPNameByParentObject(Object1) + "と" + GetPNameByParentObject(Object2) + "は垂直";
             }
             else
             {
                 Text1 = "Perpendicular";
                 Text2 = GetPNameByParentObject(Object1) + " perp. " + GetPNameByParentObject(Object2) + "";
             }
         }
         else if (PName == "平行")
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = GetPNameByParentObject(Object1) + "と" + GetPNameByParentObject(Object2) + "は平行";
             }
             else
             {
                 Text1 = "Parallel";
                 Text2 = GetPNameByParentObject(Object1) + " || " + GetPNameByParentObject(Object2) + "";
             }
         }
         else if (PName == "円 - 直線")
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = "" + GetPNameByParentObject(Object1) + "は" + GetPNameByParentObject(Object2) + "と接する";
             }
             else
             {
                 Text1 = "Tangent";
                 Text2 = "" + GetPNameByParentObject(Object1) + " tangents to " + GetPNameByParentObject(Object2) + "";
             }
         }
         else if (PName == "円 - 円")
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = "" + GetPNameByParentObject(Object1) + "は" + GetPNameByParentObject(Object2) + "と接する";
             }
             else
             {
                 Text1 = "Tangent";
                 Text2 = "" + GetPNameByParentObject(Object1) + " tangents to " + GetPNameByParentObject(Object2) + "";
             }
         }
         else if (PName == "中点")
         {
             if (AppMgr.Japanese == 1)
             {
                 if (Ratio1 == Ratio2)
                 {
                     Text1 = "" + PName;
                     Text2 = GetPNameByParentObject(Object3) + "は" + GetPNameByParentObject(Object1) + "と" + GetPNameByParentObject(Object2) + "の中点";
                 }
                 else
                 {
                     Text1 = "作図 : 内分(" + Mathf.RoundToInt(Ratio1) + "," + Mathf.RoundToInt(Ratio2) + ")";
                     Text2 = GetPNameByParentObject(Object3) + "は" + GetPNameByParentObject(Object1) + "と" + GetPNameByParentObject(Object2) + "の内分点";
                 }
             }
             else
             {
                 if (Ratio1 == Ratio2)
                 {
                     Text1 = "Midpoint";
                     Text2 = GetPNameByParentObject(Object3) + "= midpoint " + GetPNameByParentObject(Object1) + " , " + GetPNameByParentObject(Object2) + "";
                 }
                 else
                 {
                     Text1 = "Dividing(" + Mathf.RoundToInt(Ratio1) + ":" + Mathf.RoundToInt(Ratio2) + ")";
                     Text2 = GetPNameByParentObject(Object3) + "= divding pt " + GetPNameByParentObject(Object1) + " , " + GetPNameByParentObject(Object2) + "";
                 }
             }
         }
         else if (PName == "角度" && Object3 != null)
         {
             if (AppMgr.Japanese == 1)
             {
                 if (parent.GetComponent <Module>().FixAngle)
                 {
                     Text1 = "固定角 :";
                 }
                 else
                 {
                     Text1 = "角 :";
                 }
                 float angle = Mathf.FloorToInt(Constant * 180f / Mathf.PI * 10) * 0.1f;
                 Text1 += (angle + "度");
                 Text2  = "角" + GetPNameByParentObject(Object1) + "" + GetPNameByParentObject(Object2) + "" + GetPNameByParentObject(Object3);
             }
             else
             {
                 if (parent.GetComponent <Module>().FixAngle)
                 {
                     Text1 = "Fixed angle ";
                 }
                 else
                 {
                     Text1 = "Angle ";
                 }
                 float angle = Mathf.FloorToInt(Constant * 180f / Mathf.PI * 10) * 0.1f;
                 Text1 += (angle + " degree");
                 Text2  = "Angle " + GetPNameByParentObject(Object1) + "" + GetPNameByParentObject(Object2) + "" + GetPNameByParentObject(Object3);
             }
         }
         else if (PName == "角度 - 角度" && Object1 != null && Object2 != null)
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "等角 :";
                 Module md1 = Object1.GetComponent <Module>();
                 Text2 = "角" + GetPNameByParentObject(md1.Object1) + "" + GetPNameByParentObject(md1.Object2) + "" + GetPNameByParentObject(md1.Object3);
                 Module md2 = Object2.GetComponent <Module>();
                 Text2 += " = 角" + GetPNameByParentObject(md2.Object1) + "" + GetPNameByParentObject(md2.Object2) + "" + GetPNameByParentObject(md2.Object3);
             }
             else
             {
                 Text1 = "Equiangular :";
                 Module md1 = Object1.GetComponent <Module>();
                 Text2 = "Angle " + GetPNameByParentObject(md1.Object1) + "" + GetPNameByParentObject(md1.Object2) + "" + GetPNameByParentObject(md1.Object3);
                 Module md2 = Object2.GetComponent <Module>();
                 Text2 += " = Angle" + GetPNameByParentObject(md2.Object1) + "" + GetPNameByParentObject(md2.Object2) + "" + GetPNameByParentObject(md2.Object3);
             }
         }
         else
         {
             if (AppMgr.Japanese == 1)
             {
                 Text1 = "" + PName;
                 Text2 = GetPNameByParentObject(Object1) + "-" + GetPNameByParentObject(Object2);
             }
             else
             {
                 Text1 = PName;
                 Text2 = GetPNameByParentObject(Object1) + "-" + GetPNameByParentObject(Object2);
             }
         }
     }
     if (Text1.Length > 16)
     {
         int textSize = TextObj1.GetComponent <TextMesh>().fontSize;
         textSize = Mathf.FloorToInt(textSize * 16 / Text1.Length);
         TextObj1.GetComponent <TextMesh>().fontSize = textSize;
     }
     if (Text2.Length > 16)
     {
         int textSize = TextObj2.GetComponent <TextMesh>().fontSize;
         textSize = Mathf.FloorToInt(textSize * 16 / Text2.Length);
         TextObj2.GetComponent <TextMesh>().fontSize = textSize;
     }
     TextObj1.GetComponent <TextMesh>().text = Text1;
     TextObj2.GetComponent <TextMesh>().text = Text2;
     if (Position.y < -4f || Position.y > 4 || !Active || !Show)
     {
         Position.y = 100f;
     }
     transform.position = Position;
 }