Exemple #1
0
            private static void Connect(List <Vector2> left, List <Vector2> right, Vector2 A, Vector2 B, Vector2 C, float width)
            {
                Vector2 eAB = (B - A).normalized;

                float   angleABCh = Geometry2D.GetAngle(A - B, C - B) / 2;
                Vector2 eBD       = Geometry2D.RotateVector(-eAB, angleABCh);

                Vector2 D = B + eBD * ((width / 2) / Mathf.Abs(Mathf.Sin(angleABCh)));
                //Vector2 E = B - eBD * width / 2;
                Vector2 E = B + (B - D);

                Vector2 outer1 = Geometry2D.Reflection(new Geometry2D.Line(A, B), D);
                Vector2 outer2 = Geometry2D.Reflection(new Geometry2D.Line(D, E), outer1);

                List <Vector2> outer = new List <Vector2>();

                outer.Add(outer1);
                outer.Add(E);
                outer.Add(outer2);

                if (angleABCh >= 0)
                {
                    left.AddRange(outer);
                    for (int i = 0; i < 3; i++)
                    {
                        right.Add(D);
                    }
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        left.Add(D);
                    }
                    right.AddRange(outer);
                }
            }