void ModuleUpdateAngle() { Vertex VtxA = VA.GetComponent <Vertex>(); // 対象となる点A Vertex VtxB = VB.GetComponent <Vertex>(); // 対象となる点B Vertex VtxC = VC.GetComponent <Vertex>(); // 対象となる点C float FinalAngle = Mathf.Abs(ParaA * Mathf.PI / 180f); // 対象となる角 HypPoint PA = new HypPoint(VtxA.XY); HypPoint PB = new HypPoint(VtxB.XY); HypPoint PC = new HypPoint(VtxC.XY); HypPoint PO = new HypPoint(0, 0); // Bを原点に移す写像を求める。 HypLine LA = HTransform.GetHBisectorOfTwoPoints(PB, PO); HypPoint PAA = HTransform.GetInversionAlongHLine(LA, PA); HypPoint PCC = HTransform.GetInversionAlongHLine(LA, PC); //角ABCを求める float DeclineA = Mathf.Atan2(PAA.GetY(), PAA.GetX()); float DeclineC = Mathf.Atan2(PCC.GetY(), PCC.GetX()); float AngleAC = DeclineC - DeclineA; if (AngleAC > Mathf.PI) { AngleAC -= (Mathf.PI * 2f); } if (AngleAC < -Mathf.PI) { AngleAC += (Mathf.PI * 2f); } // 修正する角度をもとめる。 float error = (AngleAC - FinalAngle) * 0.1f; if (AngleAC < 0) { error = (AngleAC + FinalAngle) * 0.1f; } //今一度点の取り直し。 {//線分ABのとりなおし PA = new HypPoint(VtxA.XY); PB = new HypPoint(VtxB.XY); HypPoint PM = HTransform.GetMidPointOfTwoPoint(PA, PB); LA = HTransform.GetHBisectorOfTwoPoints(PM, PO); HypPoint PPA = HTransform.GetInversionAlongHLine(LA, PA); HypPoint PPB = HTransform.GetInversionAlongHLine(LA, PB); HypPoint NewPPA = HTransform.GetRotationOfPoint(PO, error, PPA); HypPoint NewPPB = HTransform.GetRotationOfPoint(PO, error, PPB); HypPoint NewPA = HTransform.GetInversionAlongHLine(LA, NewPPA); HypPoint NewPB = HTransform.GetInversionAlongHLine(LA, NewPPB); if (!VtxA.Fixed && NewPA.InWorld()) { VtxA.XY.x = NewPA.GetX(); VtxA.XY.y = NewPA.GetY(); } if (!VtxB.Fixed && NewPB.InWorld()) { VtxB.XY.x = NewPB.GetX(); VtxB.XY.y = NewPB.GetY(); } } {//線分BCの取り直し PC = new HypPoint(VtxC.XY); PB = new HypPoint(VtxB.XY); HypPoint PM = HTransform.GetMidPointOfTwoPoint(PC, PB); LA = HTransform.GetHBisectorOfTwoPoints(PM, PO); HypPoint PPC = HTransform.GetInversionAlongHLine(LA, PC); HypPoint PPB = HTransform.GetInversionAlongHLine(LA, PB); HypPoint NewPPC = HTransform.GetRotationOfPoint(PO, -error, PPC); HypPoint NewPPB = HTransform.GetRotationOfPoint(PO, -error, PPB); HypPoint NewPC = HTransform.GetInversionAlongHLine(LA, NewPPC); HypPoint NewPB = HTransform.GetInversionAlongHLine(LA, NewPPB); if (!VtxC.Fixed && NewPC.InWorld()) { VtxC.XY.x = NewPC.GetX(); VtxC.XY.y = NewPC.GetY(); } if (!VtxB.Fixed && NewPB.InWorld()) { VtxB.XY.x = NewPB.GetX(); VtxB.XY.y = NewPB.GetY(); } } }