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


C# Segment.GetPerpendicular方法代码示例

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


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

示例1: ConstructCircle

        public static Circle ConstructCircle(Point p1, Point p2, Point p3)
        {
            //
            // Find the center of the circle.
            //
            Segment chord1 = new Segment(p1, p2);
            Segment chord2 = new Segment(p2, p3);

            Segment perpBis1 = chord1.GetPerpendicular(chord1.Midpoint());
            Segment perpBis2 = chord2.GetPerpendicular(chord2.Midpoint());

            Point center = perpBis1.FindIntersection(perpBis2);

            //
            // Radius is the distance between the circle and any of the original points.
            //
            return new Circle(center, Point.calcDistance(center, p1));
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:18,代码来源:Circle.cs

示例2: Midpoint

        // return the midpoint between these two on the circle.
        public Point Midpoint(Point a, Point b)
        {
            if (!this.PointLiesOn(a)) return null;
            if (!this.PointLiesOn(b)) return null;

            // Make the chord.
            Segment chord = new Segment(a, b);

            Point pt1 = null;
            Point pt2 = null;

            // Is this a diameter? If so, quickly return a point perpendicular to the diameter
            if (DefinesDiameter(chord))
            {
                Segment perp = chord.GetPerpendicular(center);

                this.FindIntersection(perp, out pt1, out pt2);

                // Arbitrarily choose one of the points.
                return pt1 != null ? pt1 : pt2;
            }

            // Make radius through the midpoint of the chord.
            Segment radius = new Segment(center, chord.Midpoint());

            this.FindIntersection(radius, out pt1, out pt2);

            if (pt2 == null) return pt1;

            Point theMidpoint = Arc.StrictlyBetweenMinor(pt1, new MinorArc(this, a, b)) ? pt1 : pt2;

            double angle1 = new Angle(a, center, theMidpoint).measure;
            double angle2 = new Angle(b, center, theMidpoint).measure;
            if (!Utilities.CompareValues(angle1, angle2))
            {
                throw new ArgumentException("Midpoint is incorrect; angles do not equate: " + angle1 + " " + angle2);
            }

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

示例3: IsSecant

        //
        // Determine if the segment passes through the circle (we know it is not a chord since they have been filtered).
        //
        private bool IsSecant(Segment segment, List<Point> figPoints, out Segment chord)
        {
            // Make it null and overwrite when necessary.
            chord = null;

            // Is the segment exterior to the circle, but intersects at an endpoint (and wasn't tangent).
            if (this.PointIsExterior(segment.Point1) && this.PointLiesOn(segment.Point2)) return false;
            if (this.PointIsExterior(segment.Point2) && this.PointLiesOn(segment.Point1)) return false;

            // Is one endpoint of the segment simply on the interior of the circle (so we have nothing)?
            if (this.PointIsInterior(segment.Point1) || this.PointIsInterior(segment.Point2)) return false;

            if (ContainsDiameter(segment))
            {
                chord = ConstructChord(segment, this.center, this.radius, figPoints);

                // Add radii to the list.
                radii.Add(new Segment(this.center, chord.Point1));
                radii.Add(new Segment(this.center, chord.Point2));

                return true;
            }

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

            // Is this perpendicular segment a radius? If so, it's tangent, not a secant
            //if (Utilities.CompareValues(perpendicular.Length, this.radius)) return false;

            // Is the perpendicular a radius? Check if the intersection of the segment and the perpendicular is on the circle. If so, it's tangent
            Point intersection = segment.FindIntersection(perpendicular);
            if (this.PointLiesOn(intersection)) return false;

            //Adjust perpendicular segment to include intersection with segment
            perpendicular = new Segment(intersection, this.center);

            // Filter the fact that there are no intersections
            if (perpendicular.Length > this.radius) return false;

            //            1/2 chord length
            //                 _____   circPoint
            //                |    /
            //                |   /
            // perp.Length    |  / radius
            //                | /
            //                |/
            // Determine the half-chord length via Pyhtagorean Theorem.
            double halfChordLength = Math.Sqrt(Math.Pow(this.radius, 2) - Math.Pow(perpendicular.Length, 2));

            chord = ConstructChord(segment, perpendicular.OtherPoint(this.center), halfChordLength, figPoints);

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

示例4: 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


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