Exemple #1
0
        public static ObliqueTriangle ConstructFromVertexPositions(
            Point Pos1, Point Pos2, Point Pos3)
        {
            // setup the left most vertex, then the upper vertex and lower vertex.
            var   rv  = ObliqueTriangle.SplitLeftMostPoint(new Point[] { Pos1, Pos2, Pos3 });
            Point pt1 = rv.Item1; // pt1 is left most point

            var   rv2 = ObliqueTriangle.SplitTopMostPoint(rv.Item2);
            Point pt2 = rv2.Item1; // pt2 is top most point of pt2 and pt3.
            Point pt3 = rv2.Item2[0];

            // Create lines between the points. Line numbers match the number of the opposite
            // point.
            LineCoordinates line1 = new LineCoordinates(pt2, pt3);
            LineCoordinates line2 = new LineCoordinates(pt1, pt3);
            LineCoordinates line3 = new LineCoordinates(pt1, pt2);

            // the angle of each vertex.
            var ang1 = LineCoordinates.AngleBetween(line2, line3);
            var ang2 = LineCoordinates.AngleBetween(line1, line3);
            var ang3 = LineCoordinates.AngleBetween(line2, line1);

            var vertex1 = new TriangleVertex()
            {
                Angle    = ang1,
                Location = pt1,
                Line     = line1
            };

            var vertex2 = new TriangleVertex()
            {
                Angle    = ang2,
                Location = pt2,
                Line     = line2
            };

            var vertex3 = new TriangleVertex()
            {
                Angle    = ang3,
                Location = pt3,
                Line     = line3
            };

            var ot = new ObliqueTriangle()
            {
                Vertex1 = vertex1,
                Vertex2 = vertex2,
                Vertex3 = vertex3
            };

            return(ot);
        }
Exemple #2
0
        /// <summary>
        /// Construct an ObliqueTriangle from three lines. If the end points of all the
        /// lines do not meet to form a triangle, return null.
        /// </summary>
        /// <param name="Line1"></param>
        /// <param name="Line2"></param>
        /// <param name="Line3"></param>
        /// <returns></returns>
        public static ObliqueTriangle TryConstructFromLines(
            LineCoordinates Line1, LineCoordinates Line2, LineCoordinates Line3)
        {
            ObliqueTriangle ot = null;

            // line up the points of the lines
            var linePoints = new Point[] { Line1.Start, Line1.End, Line2.Start, Line2.End,
                                           Line3.Start, Line3.End };

            // start of line1 matches the end points of the other 2 lines.

            return(ot);
        }