Ejemplo n.º 1
0
        public bool IsCoplanarTo(gEdge edge)
        {
            // http://mathworld.wolfram.com/Coplanar.html
            gVector a = this.Direction;
            gVector b = edge.Direction;
            gVector c = gVector.ByTwoVertices(this.StartVertex, edge.StartVertex);

            return(c.Dot(a.Cross(b)) == 0);
        }
Ejemplo n.º 2
0
        public bool OnEdge(gVertex start, gVertex end)
        {
            if (this.Equals(start) || this.Equals(end))
            {
                return(true);
            }
            // https://www.lucidarme.me/check-if-a-point-belongs-on-a-line-segment/
            gVector startEnd = gVector.ByTwoVertices(start, end);
            gVector startMid = gVector.ByTwoVertices(start, this);
            gVector endMid   = gVector.ByTwoVertices(this, end);

            if (!startMid.IsParallelTo(endMid))
            {
                return(false);
            }                                                    // Not aligned
            double dotAC = startEnd.Dot(startMid);
            double dotAB = startEnd.Dot(startEnd);

            return(0 <= dotAC && dotAC <= dotAB);
        }