Exemplo n.º 1
0
        static public IEnumerable <Vector2> GetPoints(this Triangle2 item)
        {
            yield return(item.v0);

            yield return(item.v1);

            yield return(item.v2);
        }
Exemplo n.º 2
0
        static public IEnumerable <Triangle2> SplitAlongEdge20ByPercent(this Triangle2 item, float percent)
        {
            Vector2 vertex = item.GetEdge20().GetPointOnByPercent(percent);

            yield return(new Triangle2(item.v0, item.v1, vertex));

            yield return(new Triangle2(vertex, item.v1, item.v2));
        }
Exemplo n.º 3
0
        static public IEnumerable <Triangle2> Fantize(this Triangle2 item, Vector2 point)
        {
            yield return(new Triangle2(item.v0, item.v1, point));

            yield return(new Triangle2(item.v1, item.v2, point));

            yield return(new Triangle2(item.v2, item.v0, point));
        }
Exemplo n.º 4
0
 static public Triangle3 InflateTriangle(this PlaneSpace item, Triangle2 triangle)
 {
     return(new Triangle3(
                item.InflatePoint(triangle.v0),
                item.InflatePoint(triangle.v1),
                item.InflatePoint(triangle.v2)
                ));
 }
Exemplo n.º 5
0
        public PolygonTriangle(Triangle2 t)
        {
            triangle = t;

            f1 = triangle.GetEdge01().GetFace();
            f2 = triangle.GetEdge12().GetFace();
            f3 = triangle.GetEdge20().GetFace();
        }
Exemplo n.º 6
0
        static public IEnumerable <Triangle2> RecursiveFantizeAtCenterByArea(this Triangle2 item, float min_area, int max_recursions)
        {
            if (item.GetArea() > min_area && max_recursions >= 1)
            {
                return(item.FantizeAtCenter()
                       .Convert(t => t.RecursiveFantizeAtCenterByArea(min_area, max_recursions - 1))
                       .Flatten());
            }

            return(item.WrapAsEnumerable());
        }
Exemplo n.º 7
0
        static public bool TryCreateTriangle(this Face item, Face face, out Triangle2 triangle, out Face missing)
        {
            if (item.TryCreateTriangle(face, out triangle))
            {
                missing = FaceExtensions.CreatePoints(face.v1, item.v0);
                return(true);
            }

            missing = default(Face);
            return(false);
        }
Exemplo n.º 8
0
        static public IEnumerable <Triangle2> RecursiveSplitSpiralAlongEdgeByArea(this Triangle2 item, float p, float dp, float min_area, int max_recursions)
        {
            if (item.GetArea() > min_area && max_recursions >= 1)
            {
                return(item.SplitAlongEdgeByPercent(p)
                       .Convert(t => t.RecursiveSplitSpiralAlongEdgeByArea(p + dp, dp, min_area, max_recursions - 1))
                       .Flatten());
            }

            return(item.WrapAsEnumerable());
        }
Exemplo n.º 9
0
        static public bool TryCreateTriangle(this Face item, Face face, out Triangle2 triangle)
        {
            if (item.v1 == face.v0)
            {
                if (item.IsInside(face.v1))
                {
                    triangle = new Triangle2(item.v0, face.v0, face.v1);
                    return(true);
                }
            }

            triangle = default(Triangle2);
            return(false);
        }
Exemplo n.º 10
0
        static public bool IsIntersecting(this Plane2 item, Triangle2 triangle, out LineSegment2 output)
        {
            Vector2 v0;
            Vector2 v1;

            if (triangle.GetEdges()
                .TryConvert((LineSegment2 e, out Vector2 v) => item.IsIntersecting(e, out v))
                .PartOut(out v0, out v1) == 2)
            {
                output = new LineSegment2(v0, v1);
                return(true);
            }

            output = default(LineSegment2);
            return(false);
        }
Exemplo n.º 11
0
        static public IEnumerable <Triangle2> SplitAlongEdgeByPercent(this Triangle2 item, float percent)
        {
            percent = percent.GetLooped(3.0f);

            if (percent < 1.0f)
            {
                return(item.SplitAlongEdge01ByPercent(percent));
            }

            if (percent < 2.0f)
            {
                return(item.SplitAlongEdge12ByPercent(percent - 1.0f));
            }

            return(item.SplitAlongEdge20ByPercent(percent - 2.0f));
        }
Exemplo n.º 12
0
        static public Vector2 GetPointOnEdgeByPercent(this Triangle2 item, float percent)
        {
            percent = percent.GetLooped(3.0f);

            if (percent < 1.0f)
            {
                return(item.GetEdge01().GetPointOnByPercent(percent));
            }

            if (percent < 2.0f)
            {
                return(item.GetEdge12().GetPointOnByPercent(percent - 1.0f));
            }

            return(item.GetEdge20().GetPointOnByPercent(percent - 2.0f));
        }
Exemplo n.º 13
0
 static public IEnumerable <Triangle2> FantizeAtCenter(this Triangle2 item)
 {
     return(item.Fantize(item.GetCenter()));
 }
Exemplo n.º 14
0
 static public Vector2 GetCenter(this Triangle2 item)
 {
     return(item.GetPoints().Average());
 }
Exemplo n.º 15
0
 static public void DrawTriangle(Triangle2 triangle)
 {
     Gizmos.DrawLine(triangle.v0, triangle.v1);
     Gizmos.DrawLine(triangle.v1, triangle.v2);
     Gizmos.DrawLine(triangle.v2, triangle.v0);
 }
Exemplo n.º 16
0
 static public IEnumerable <LineSegment2> GetEdges(this Triangle2 item)
 {
     return(item.GetPoints().CloseLoop().Connect());
 }
Exemplo n.º 17
0
 static public LineSegment2 GetEdge20(this Triangle2 item)
 {
     return(new LineSegment2(item.v2, item.v0));
 }
Exemplo n.º 18
0
 static public LineSegment2 GetEdge12(this Triangle2 item)
 {
     return(new LineSegment2(item.v1, item.v2));
 }
Exemplo n.º 19
0
 static public float GetArea(this Triangle2 item)
 {
     return(item.GetPoints().GetLoopArea());
 }
Exemplo n.º 20
0
 static public Rect GetRect(this Triangle2 item)
 {
     return(RectExtensions.CreatePoints(item.GetPoints()));
 }
Exemplo n.º 21
0
 static public void AddTriangle(this MeshBuilder item, Triangle2 triangle)
 {
     item.AddTriangle(triangle.v0, triangle.v1, triangle.v2);
 }
Exemplo n.º 22
0
 static public Triangle2 GetReversedWinding(this Triangle2 item)
 {
     return(new Triangle2(item.v2, item.v1, item.v0));
 }
Exemplo n.º 23
0
 static public LineSegment2 GetEdge01(this Triangle2 item)
 {
     return(new LineSegment2(item.v0, item.v1));
 }
Exemplo n.º 24
0
 static public Bounds GetBounds(this Triangle2 item)
 {
     return(BoundsExtensions.CreateWithPoints(item.GetPoints().GetSpacar()));
 }