当前位置: 首页>>代码示例>>C#>>正文


C# Segment.PointLiesOnAndBetweenEndpoints方法代码示例

本文整理汇总了C#中GeometryTutorLib.ConcreteAST.Segment.PointLiesOnAndBetweenEndpoints方法的典型用法代码示例。如果您正苦于以下问题:C# Segment.PointLiesOnAndBetweenEndpoints方法的具体用法?C# Segment.PointLiesOnAndBetweenEndpoints怎么用?C# Segment.PointLiesOnAndBetweenEndpoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeometryTutorLib.ConcreteAST.Segment的用法示例。


在下文中一共展示了Segment.PointLiesOnAndBetweenEndpoints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CoordinateMedian

        public bool CoordinateMedian(Segment thatSegment)
        {
            //
            // Two sides must intersect the median at a single point
            //
            Point midptIntersection = null;
            Point coincidingIntersection = null;
            Segment oppSide = null;
            if (Segment.IntersectAtSamePoint(SegmentA, SegmentB, thatSegment))
            {
                coincidingIntersection = SegmentA.FindIntersection(SegmentB);
                midptIntersection = SegmentC.FindIntersection(thatSegment);
                oppSide = SegmentC;
            }
            else if (Segment.IntersectAtSamePoint(SegmentA, SegmentC, thatSegment))
            {
                coincidingIntersection = SegmentA.FindIntersection(SegmentC);
                midptIntersection = SegmentB.FindIntersection(thatSegment);
                oppSide = SegmentB;
            }
            else if (Segment.IntersectAtSamePoint(SegmentB, SegmentC, thatSegment))
            {
                coincidingIntersection = SegmentB.FindIntersection(SegmentC);
                midptIntersection = SegmentA.FindIntersection(thatSegment);
                oppSide = SegmentA;
            }

            if (midptIntersection == null || oppSide == null) return false;

            // It is possible for the segment to be parallel to the opposite side; results in NaN.
            if (midptIntersection.X == double.NaN || midptIntersection.Y == double.NaN) return false;

            // The intersection must be on the potential median
            if (!thatSegment.PointLiesOnAndBetweenEndpoints(coincidingIntersection)) return false;

            // The midpoint intersection must be on the potential median
            if (!thatSegment.PointLiesOnAndBetweenEndpoints(midptIntersection)) return false;

            if (!Segment.Between(coincidingIntersection, thatSegment.Point1, thatSegment.Point2)) return false;

            if (!oppSide.PointLiesOnAndBetweenEndpoints(midptIntersection)) return false;

            // Midpoint of the remaining side needs to align
            return midptIntersection.Equals(oppSide.Midpoint());
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:45,代码来源:Triangle.cs

示例2: FindIntersection

        public override void FindIntersection(Segment that, out Point inter1, out Point inter2)
        {
            // Find the points of intersection
            this.theCircle.FindIntersection(that, out inter1, out inter2);

            // The points must be on this minor arc.
            if (this is MinorArc)
            {
                if (!Arc.BetweenMinor(inter1, this)) inter1 = null;
                if (!Arc.BetweenMinor(inter2, this)) inter2 = null;
            }
            else if (this is MajorArc)
            {
                if (!Arc.BetweenMajor(inter1, this)) inter1 = null;
                if (!Arc.BetweenMajor(inter2, this)) inter2 = null;
            }
            else if (this is Semicircle)
            {
                if (!(this as Semicircle).PointLiesOn(inter1)) inter1 = null;
                if (!(this as Semicircle).PointLiesOn(inter2)) inter2 = null;
            }

            if (!that.PointLiesOnAndBetweenEndpoints(inter1)) inter1 = null;
            if (!that.PointLiesOnAndBetweenEndpoints(inter2)) inter2 = null;

            if (inter1 == null && inter2 != null)
            {
                inter1 = inter2;
                inter2 = null;
            }
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:31,代码来源:Arc.cs

示例3: CoordinateAltitude

        //
        // Is this segment an altitude based on the coordinates (precomputation)
        //
        public bool CoordinateAltitude(Segment thatSegment)
        {
            //
            // Check to see if the altitude is actually one of the sides of the triangle
            //
            if (this.HasSegment(thatSegment) && this.isRight)
            {
                // Find the right angle; the altitude must be one of those segments
                if (Utilities.CompareValues(this.AngleA.measure, 90)) return AngleA.HasSegment(thatSegment);
                if (Utilities.CompareValues(this.AngleB.measure, 90)) return AngleB.HasSegment(thatSegment);
                if (Utilities.CompareValues(this.AngleC.measure, 90)) return AngleC.HasSegment(thatSegment);
            }

            //
            // Two sides must intersect the given segment at a single point
            //
            Point otherIntersection = null;
            Point thisIntersection = null;
            Segment oppSide = null;
            if (Segment.IntersectAtSamePoint(SegmentA, SegmentB, thatSegment))
            {
                thisIntersection = SegmentA.FindIntersection(SegmentB);
                otherIntersection = SegmentC.FindIntersection(thatSegment);
                oppSide = SegmentC;
            }
            if (Segment.IntersectAtSamePoint(SegmentA, SegmentC, thatSegment))
            {
                thisIntersection = SegmentA.FindIntersection(SegmentC);
                otherIntersection = SegmentB.FindIntersection(thatSegment);
                oppSide = SegmentB;
            }
            if (Segment.IntersectAtSamePoint(SegmentB, SegmentC, thatSegment))
            {
                thisIntersection = SegmentB.FindIntersection(SegmentC);
                otherIntersection = SegmentA.FindIntersection(thatSegment);
                oppSide = SegmentA;
            }

            if (otherIntersection == null || oppSide == null) return false;

            // Avoid a dangling altitude:
            //
            // |\
            // | \
            // |  \
            //     \
            // Need to make sure 'this' and the the 'other' intersection is actually on the potential altitude segment
            if (!thatSegment.PointLiesOnAndBetweenEndpoints(thisIntersection)) return false;
            if (!thatSegment.PointLiesOnAndBetweenEndpoints(otherIntersection)) return false;

            // We require a perpendicular intersection
            return Utilities.CompareValues((new Angle(thisIntersection, otherIntersection, oppSide.Point1)).measure, 90);
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:56,代码来源:Triangle.cs

示例4: ContainsDiameter

        //
        // Does the given segment pass through the circle so that it acts as a diameter (or contains a diameter)?
        //
        private bool ContainsDiameter(Segment segment)
        {
            if (!segment.PointLiesOnAndBetweenEndpoints(this.center)) return false;

            // the endpoints of the segment must be on or outside the circle.
            double distance = Point.calcDistance(this.center, segment.Point1);
            if (distance < this.radius) return false;

            distance = Point.calcDistance(this.center, segment.Point2);
            if (distance < this.radius) return false;

            return true;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:16,代码来源:Circle.cs

示例5: InstantiateToDef

        //
        // Construct the AngleBisector if we have
        //
        //      V---------------A
        //     / \
        //    /   \
        //   /     \
        //  B       C
        //
        // Congruent(Angle, A, V, C), Angle(C, V, B)),  Segment(V, C)) -> AngleBisector(Angle(A, V, B)
        //
        //
        private static List<EdgeAggregator> InstantiateToDef(CongruentAngles cas, Segment segment)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Find the shared segment between the two angles; we know it is valid if we reach this point
            Segment shared = cas.AreAdjacent();

            // The bisector must align with the given segment
            if (!segment.IsCollinearWith(shared)) return newGrounded;

            // We need a true bisector in which the shared vertex of the angles in between the endpoints of this segment
            if (!segment.PointLiesOnAndBetweenEndpoints(cas.ca1.GetVertex())) return newGrounded;

            //
            // Create the overall angle which is being bisected
            //
            Point vertex = cas.ca1.GetVertex();
            Segment newRay1 = cas.ca1.OtherRayEquates(shared);
            Segment newRay2 = cas.ca2.OtherRayEquates(shared);
            Angle combinedAngle = new Angle(newRay1.OtherPoint(vertex), vertex, newRay2.OtherPoint(vertex));

            // Determine if the segment is a straight angle (we don't want an angle bisector here, we would want a segment bisector)
            if (newRay1.IsCollinearWith(newRay2)) return newGrounded;

            // The bisector cannot be of the form:
            //    \
            //     \
            //      V---------------A
            //     /
            //    /
            //   B
            if (!combinedAngle.IsOnInteriorExplicitly(segment.Point1) && !combinedAngle.IsOnInteriorExplicitly(segment.Point2)) return newGrounded;

            AngleBisector newAB = new AngleBisector(combinedAngle, segment);

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(segment);
            antecedent.Add(cas);

            newGrounded.Add(new EdgeAggregator(antecedent, newAB, annotation));
            return newGrounded;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:55,代码来源:AngleBisectorDefinition.cs

示例6: HasSegment

 public bool HasSegment(Segment thatSegment)
 {
     return segment.HasSubSegment(thatSegment) && thatSegment.PointLiesOnAndBetweenEndpoints(intersect);
 }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:4,代码来源:CircleSegmentIntersection.cs

示例7: IsTangent

        //
        // Determine tangency of the given segment.
        // Indicate tangency by returning the segment which creates the 90^0 angle.
        //
        public Segment IsTangent(Segment segment)
        {
            // If the center and the segment points are collinear, this will not be a tangent.
            if (segment.PointLiesOn(this.center)) return null;

            // Acquire the line perpendicular to the segment that passes through the center of the circle.
            Segment perpendicular = segment.GetPerpendicular(this.center);

            // If the segment was found to pass through the center, it is not a tangent
            if (perpendicular.Equals(segment)) return null;

            // Is this perpendicular segment a radius? Check length
            //if (!Utilities.CompareValues(perpendicular.Length, this.radius)) return null;

            // Is the perpendicular a radius? Check that the intersection of the segment and the perpendicular is on the circle
            Point intersection = segment.FindIntersection(perpendicular);
            if (!this.PointLiesOn(intersection)) return null;

            // The intersection between the perpendicular and the segment must be within the endpoints of the segment.
            return segment.PointLiesOnAndBetweenEndpoints(intersection) ? perpendicular : null;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:25,代码来源:Circle.cs

示例8: FindIntersection

        public override void FindIntersection(Segment that, out Point inter1, out Point inter2)
        {
            inter1 = FindIntersection(that);
            inter2 = null;

            if (!this.PointLiesOnAndBetweenEndpoints(inter1)) inter1 = null;
            if (!that.PointLiesOnAndBetweenEndpoints(inter1)) inter1 = null;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:8,代码来源:Segment.cs

示例9: FindIntersection

        public override void FindIntersection(Segment that, out Point inter1, out Point inter2)
        {
            inter1 = null;
            inter2 = null;

            Point foundInter = null;
            List<Point> intersections = new List<Point>();
            foreach (Segment side in orderedSides)
            {
                if (side.IsCollinearWith(that))
                {
                    if (that.PointLiesOnAndBetweenEndpoints(side.Point1)) Utilities.AddStructurallyUnique<Point>(intersections, side.Point1);
                    if (that.PointLiesOnAndBetweenEndpoints(side.Point2)) Utilities.AddStructurallyUnique<Point>(intersections, side.Point2);

                    if (side.PointLiesOnAndBetweenEndpoints(that.Point1)) Utilities.AddStructurallyUnique<Point>(intersections, that.Point1);
                    if (side.PointLiesOnAndBetweenEndpoints(that.Point2)) Utilities.AddStructurallyUnique<Point>(intersections, that.Point2);
                }
                else
                {
                    foundInter = side.FindIntersection(that);

                    // Is the intersection in the middle of the segments?
                    if (side.PointLiesOnAndBetweenEndpoints(foundInter) && that.PointLiesOnAndBetweenEndpoints(foundInter))
                    {
                        // A segment may intersect a polygon through up to 2 vertices creating 4 intersections.
                        if (!Utilities.HasStructurally<Point>(intersections, foundInter)) intersections.Add(foundInter);
                    }
                }
            }
            if (!(this is ConcavePolygon) && intersections.Count > 2)
            {
                throw new Exception("A segment intersecting a polygon may have up to 2 intersection points, not: " + intersections.Count);
            }

            if (intersections.Any()) inter1 = intersections[0];
            if (intersections.Count > 1) inter2 = intersections[1];
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:37,代码来源:Polygon.cs

示例10: CoordinateBisector

        //
        // Is thatSegment a bisector of this segment in terms of the coordinatization from the UI?
        //
        public Point CoordinateBisector(Segment thatSegment)
        {
            // Do these segments intersect within both sets of stated endpoints?
            Point intersection = this.FindIntersection(thatSegment);

            if (!this.PointLiesOnAndExactlyBetweenEndpoints(intersection)) return null;
            if (!thatSegment.PointLiesOnAndBetweenEndpoints(intersection)) return null;

            // Do they intersect in the middle of this segment
            return Utilities.CompareValues(Point.calcDistance(this.Point1, intersection), Point.calcDistance(this.Point2, intersection)) ? intersection : null;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:14,代码来源:Segment.cs

示例11: CoordinatePerpendicular

        //
        // Is this segment perpendicular to the given segment in terms of the coordinatization from the UI?
        //
        public Point CoordinatePerpendicular(Segment thatSegment)
        {
            //
            // Do these segments intersect within both sets of stated endpoints?
            //
            Point intersection = this.FindIntersection(thatSegment);

            if (!this.PointLiesOnAndBetweenEndpoints(intersection)) return null;
            if (!thatSegment.PointLiesOnAndBetweenEndpoints(intersection)) return null;

            //
            // Special Case
            //
            if ((IsVertical() && thatSegment.IsHorizontal()) || (thatSegment.IsVertical() && IsHorizontal())) return intersection;

            // Does m1 * m2 = -1 (opposite reciprocal slopes)
            return Utilities.CompareValues(thatSegment.Slope * this.Slope, -1) ? intersection : null;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:21,代码来源:Segment.cs

示例12: InstantiateToDef

        //
        // Take the angle congruence and bisector and create the AngleBisector relation
        //              \
        //               \
        //     B ---------V---------A
        //                 \
        //                  \
        //                   C
        //
        private static List<EdgeAggregator> InstantiateToDef(Point intersectionPoint, Intersection inter, CongruentSegments cs)
        {
            List<EdgeAggregator> newGrounded = new List<EdgeAggregator>();

            // Does the given point of intersection apply to this actual intersection object
            if (!intersectionPoint.Equals(inter.intersect)) return newGrounded;

            // The entire segment AB
            Segment overallSegment = new Segment(cs.cs1.OtherPoint(intersectionPoint), cs.cs2.OtherPoint(intersectionPoint));

            // The segment must align completely with one of the intersection segments
            Segment interCollinearSegment = inter.GetCollinearSegment(overallSegment);
            if (interCollinearSegment == null) return newGrounded;

            // Does this intersection have the entire segment AB
            if (!inter.HasSegment(overallSegment)) return newGrounded;

            Segment bisector = inter.OtherSegment(overallSegment);
            Segment bisectedSegment = inter.GetCollinearSegment(overallSegment);

            // Check if the bisected segment extends is the exact same segment as the overall segment AB
            if (!bisectedSegment.StructurallyEquals(overallSegment))
            {
                if (overallSegment.PointLiesOnAndBetweenEndpoints(bisectedSegment.Point1) &&
                    overallSegment.PointLiesOnAndBetweenEndpoints(bisectedSegment.Point2)) return newGrounded;
            }

            SegmentBisector newSB = new SegmentBisector(inter, bisector);

            // For hypergraph
            List<GroundedClause> antecedent = new List<GroundedClause>();
            antecedent.Add(inter);
            antecedent.Add(cs);

            newGrounded.Add(new EdgeAggregator(antecedent, newSB, annotation));
            return newGrounded;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:46,代码来源:SegmentBisectorDefinition.cs

示例13: CoordinateAngleBisector

        public bool CoordinateAngleBisector(Segment thatSegment)
        {
            if (!thatSegment.PointLiesOnAndBetweenEndpoints(this.GetVertex())) return false;

            if (thatSegment.IsCollinearWith(this.ray1) || thatSegment.IsCollinearWith(this.ray2)) return false;

            Point interiorPoint = this.IsOnInteriorExplicitly(thatSegment.Point1) ? thatSegment.Point1 : thatSegment.Point2;
            if (!this.IsOnInteriorExplicitly(interiorPoint)) return false;

            Angle angle1 = new Angle(A, GetVertex(), interiorPoint);
            Angle angle2 = new Angle(C, GetVertex(), interiorPoint);

            return Utilities.CompareValues(angle1.measure, angle2.measure);
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:14,代码来源:Angle.cs

示例14: PointLiesOn

        //
        // Point is on the perimeter?
        //
        public override bool PointLiesOn(Point pt)
        {
            if (pt == null) return false;

            // Radii
            KeyValuePair<Segment, Segment> radii = theArc.GetRadii();
            if (radii.Key.PointLiesOnAndBetweenEndpoints(pt) || radii.Value.PointLiesOnAndBetweenEndpoints(pt)) return true;

            // This point must lie on the circle in question, minimally.
            if (!theArc.theCircle.PointLiesOn(pt)) return false;

            // Arc
            if (theArc is MajorArc) return Arc.BetweenMajor(pt, theArc as MajorArc);
            else if (theArc is MinorArc) return Arc.BetweenMinor(pt, theArc as MinorArc);
            else if (theArc is Semicircle)
            {
                Semicircle semi = theArc as Semicircle;

                // The point in question must lie on the same side of the diameter as the middle point
                Segment candSeg = new Segment(pt, semi.middlePoint);

                Point intersection = semi.diameter.FindIntersection(candSeg);

                return !candSeg.PointLiesOnAndBetweenEndpoints(intersection);
            }

            return false;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:31,代码来源:Sector.cs

示例15: PointLiesInside

        //
        // Point must be in the given circle and then, specifically in the specified angle
        //
        public override bool PointLiesInside(Point pt)
        {
            // Is the point in the sector's circle?
            if (!theArc.theCircle.PointLiesInside(pt)) return false;

            // Radii
            if (radius1.PointLiesOnAndBetweenEndpoints(pt)) return false;
            if (radius2.PointLiesOnAndBetweenEndpoints(pt)) return false;

            //
            // For the Minor Arc, create two angles.
            // The sum must equal the measure of the angle created by the endpoints.
            //
            double originalMinorMeasure = theArc.minorMeasure;
            double centralAngle1 = new Angle(theArc.endpoint1, theArc.theCircle.center, pt).measure;
            double centralAngle2 = new Angle(theArc.endpoint2, theArc.theCircle.center, pt).measure;

            bool isInMinorArc = Utilities.CompareValues(theArc.minorMeasure, centralAngle1 + centralAngle2);

            if (theArc is MinorArc) return isInMinorArc;

            if (theArc is MajorArc) return !isInMinorArc;

            if (theArc is Semicircle)
            {
                Semicircle semi = theArc as Semicircle;

                // The point in question must lie on the same side of the diameter as the middle point
                Segment candSeg = new Segment(pt, semi.middlePoint);

                Point intersection = semi.diameter.FindIntersection(candSeg);

                return !candSeg.PointLiesOnAndBetweenEndpoints(intersection);
            }

            return false;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:40,代码来源:Sector.cs


注:本文中的GeometryTutorLib.ConcreteAST.Segment.PointLiesOnAndBetweenEndpoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。