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


C# Segment.IsVertical方法代码示例

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


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

示例1: ConstructChord

        //
        // Given the secant, there is a midpoint along the secant (wrt to the circle), given the distance,
        // find the two points of intersection between the secant and the circle.
        // Return the resultant chord segment.
        //
        private Segment ConstructChord(Segment secantSegment, Point midpt, double distance, List<Point> figPoints)
        {
            //                distance
            //      circPt1    _____   circPt2
            //
            // Find the exact coordinates of the two 'circ' points.
            //
            double deltaX = 0;
            double deltaY = 0;
            if (secantSegment.IsVertical())
            {
                deltaX = 0;
                deltaY = distance;
            }
            else if (secantSegment.IsHorizontal())
            {
                deltaX = distance;
                deltaY = 0;
            }
            else
            {
                deltaX = Math.Sqrt(Math.Pow(distance, 2) / (1 + Math.Pow(secantSegment.Slope, 2)));
                deltaY = secantSegment.Slope * deltaX;
            }
            Point circPt1 = Utilities.AcquirePoint(figPoints, new Point("", midpt.X + deltaX, midpt.Y + deltaY));

            // intersection is the midpoint of circPt1 and pt2.
            Point circPt2 = Utilities.AcquirePoint(figPoints, new Point("", 2 * midpt.X - circPt1.X, 2 * midpt.Y - circPt1.Y));

            // Create the actual chord
            return new Segment(circPt1, circPt2);
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:37,代码来源:Circle.cs

示例2: IsPerpendicularTo

        //
        // Parallel and not Coinciding
        //
        public bool IsPerpendicularTo(Segment thatSegment)
        {
            if (IsVertical() && thatSegment.IsHorizontal()) return true;

            if (IsHorizontal() && thatSegment.IsVertical()) return true;

            return Utilities.CompareValues(thatSegment.Slope * this.Slope, -1);
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:11,代码来源:Segment.cs

示例3: IsParallelWith

        //
        // Parallel and not Coinciding
        //
        public bool IsParallelWith(Segment s)
        {
            if (IsCollinearWith(s)) return false;

            if (IsVertical() && s.IsVertical()) return true;

            if (IsHorizontal() && s.IsHorizontal()) return true;

            return Utilities.CompareValues(s.Slope, this.Slope);
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:13,代码来源:Segment.cs

示例4: IsCollinearWith

        //
        // Determine if the given segment is collinear with this segment (same slope and they share a point)
        //
        public bool IsCollinearWith(Segment otherSegment)
        {
            // If the segments are vertical, just compare the X values of one point of each
            if (this.IsVertical() && otherSegment.IsVertical())
            {
                return Utilities.CompareValues(this.Point1.X, otherSegment.Point1.X);
            }

            // If the segments are horizontal, just compare the Y values of one point of each; this is redundant
            if (this.IsHorizontal() && otherSegment.IsHorizontal())
            {
                return Utilities.CompareValues(this.Point1.Y, otherSegment.Point1.Y);
            }

            return Utilities.CompareValues(this.Slope, otherSegment.Slope) &&
                   this.PointLiesOn(otherSegment.Point1) && this.PointLiesOn(otherSegment.Point2); // Check both endpoints just to be sure
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:20,代码来源:Segment.cs

示例5: FindIntersection

        public Point FindIntersection(Segment thatSegment)
        {
            // Special Case: Collinear, but non-overlapping.
            if (this.CoincidingWithoutOverlap(thatSegment)) return null;

            // Special Case: Intersect at an endpoint
            Point shared = this.SharedVertex(thatSegment);
            if (shared != null) return shared;

            double a, b, c, d, e, f;

            if (this.IsVertical() && thatSegment.IsHorizontal()) return new Point(null, this.Point1.X, thatSegment.Point1.Y);

            if (thatSegment.IsVertical() && this.IsHorizontal()) return new Point(null, thatSegment.Point1.X, this.Point1.Y);

            if (this.IsVertical())
            {
                MakeLine(thatSegment.Point1.X, thatSegment.Point1.Y, thatSegment.Point2.X, thatSegment.Point2.Y, out a, out b, out e);
                return new Point(null, this.Point1.X, EvaluateYGivenX(a, b, e, this.Point1.X));
            }
            if (thatSegment.IsVertical())
            {
                MakeLine(this.Point1.X, this.Point1.Y, this.Point2.X, this.Point2.Y, out a, out b, out e);
                return new Point(null, thatSegment.Point1.X, EvaluateYGivenX(a, b, e, thatSegment.Point1.X));
            }
            if (this.IsHorizontal())
            {
                MakeLine(thatSegment.Point1.X, thatSegment.Point1.Y, thatSegment.Point2.X, thatSegment.Point2.Y, out a, out b, out e);
                return new Point(null, EvaluateXGivenY(a, b, e, this.Point1.Y), this.Point1.Y);
            }
            if (thatSegment.IsHorizontal())
            {
                MakeLine(this.Point1.X, this.Point1.Y, this.Point2.X, this.Point2.Y, out a, out b, out e);
                return new Point(null, EvaluateXGivenY(a, b, e, thatSegment.Point1.Y), thatSegment.Point1.Y);
            }

            //
            // ax + by = e
            // cx + dy = f
            //

            MakeLine(Point1.X, Point1.Y, Point2.X, Point2.Y, out a, out b, out e);
            MakeLine(thatSegment.Point1.X, thatSegment.Point1.Y, thatSegment.Point2.X, thatSegment.Point2.Y, out c, out d, out f);

            double overallDeterminant = a * d - b * c;
            double x = determinant(e, b, f, d) / overallDeterminant;
            double y = determinant(a, e, c, f) / overallDeterminant;

            return new Point("Intersection", x, y);
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:50,代码来源:Segment.cs

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


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