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


C# Turn.GetAngleInRadians方法代码示例

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


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

示例1: CreateIntersectGeometry

        /// <summary>
        /// Creates the geometry that can be used to detect intersections with the map.
        /// </summary>
        /// <returns>The geometry for the new line (null if insufficient information has been specified)</returns>
        ArcGeometry CreateIntersectGeometry()
        {
            if (m_Circles==null)
                return null;

            PointFeature start = StartPoint;
            if (start==null)
                return null;

            IPointGeometry end = LastMousePosition;
            if (end==null)
                return null;

            ITerminal endTerm = new FloatingTerminal(end);

            // Find the circle that is closest to the end (only looking at the valid circles
            // that are within a 1mm tolerance). Return null geometry if none of the circles
            // are within reach.

            Circle bestCircle = m_Circles[0];
            double bestdist = bestCircle.Distance(end).Meters;

            if (m_Circles.Count > 1)
            {
                // See if there is any better choice
                for (int i=1; i<m_Circles.Count; i++)
                {
                    Circle c = m_Circles[i];
                    double dist = c.Distance(end).Meters;
                    if (dist < bestdist)
                    {
                        bestCircle = c;
                        bestdist = dist;
                    }
                }
            }

            // Ignore if the best circle is too far away
            double tol = CircleTolerance.Meters;
            if (bestdist > tol)
                return null;

            // Project the end point ON to the circle.
            //IPointGeometry center = bestCircle.Center;
            //Turn eturn = new Turn(center, end);
            //IAngle bearing = eturn.Bearing;
            //IPosition cirend = Geom.Polar(center, bearing.Radians, bestCircle.Radius.Meters);
            IPosition cirend = CircleGeometry.GetClosestPosition(bestCircle, end);

            // Get the clockwise angle from the start to the current end point.
            IPointGeometry center = bestCircle.Center;
            Turn sturn = new Turn(center, start);
            double angle = sturn.GetAngleInRadians(cirend);

            // Figure out which direction the curve should go, depending
            // on whether the user wants the short arc or the long one.
            bool iscw = (angle < MathConstants.PI ? m_IsShortArc : !m_IsShortArc);

            // Create the required geometry
            ITerminal ec = new FloatingTerminal(cirend);
            return new ArcGeometry(bestCircle, start, ec, iscw);
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:66,代码来源:NewCircularArcUI.cs

示例2: EndIntersect

        /// <summary>
        /// Intersects a pair of clockwise arcs, where one of the ends exactly coincides with the
        /// other arc. The two arcs are assumed to sit on different circles.
        /// </summary>
        /// <param name="xsect">The intersection results.</param>
        /// <param name="bc">The start of the other arc.</param>
        /// <param name="ec">The end of the other arc.</param>
        /// <param name="circle">The circle that the other arc sits on.</param>
        /// <param name="xend">The end of THIS arc that coincides with one end of the other one.</param>
        /// <param name="othend">The other end of THIS arc (may or may not coincide with one end of
        /// the other arc).</param>
        /// <param name="xCircle">The circle for THIS arc</param>
        /// <returns>The number of intersections (1 or 2).</returns>
        static uint EndIntersect( IntersectionResult xsect
            , ICircularArcGeometry ab
            , ICircularArcGeometry pq
            , bool isFirstEndCoincident)
        {
            IPointGeometry bc = pq.First;
            IPointGeometry ec = pq.Second;
            ICircleGeometry circle = pq.Circle;
            IPointGeometry xend = (isFirstEndCoincident ? ab.First : ab.Second);
            IPointGeometry othend = (isFirstEndCoincident ? ab.Second : ab.First);
            ICircleGeometry xCircle = ab.Circle;

            // The two curves sit on different circles, so do a precise intersection of the circles.
            IPointGeometry c1 = xCircle.Center;
            IPointGeometry c2 = circle.Center;
            double r1 = xCircle.Radius;
            double r2 = circle.Radius;
            IPosition x1, x2;
            uint nx = Geom.IntersectCircles(c1, r1, c2, r2, out x1, out x2);

            // If we didn't get ANY intersections, that's a bit unusual
            // seeing how one of the ends matches. However, it's possible
            // due to roundoff of the end locations. So in that case, just
            // return a single intersection at the matching end.
            if (nx==0)
            {
                xsect.Append(xend);
                return 1;
            }

            // @devnote If we got 1 intersection (i.e. the 2 circles just
            // touch), you might be tempted to think that it must be close
            // to the matching end location. That is NOT the case if the
            // circles are big.

            // If we got 2 intersections, pick the one that's further away
            // than the matching end.
            if (nx==2 && Geom.DistanceSquared(x2, xend) > Geom.DistanceSquared(x1, xend))
                x1 = x2;

            // That leaves us with ONE intersection with the circle ... now
            // confirm that it actually intersects both curves!

            // Does it fall in the sector defined by the clockwise curve?

            IPointGeometry centre = c2;
            Turn reft = new Turn(centre, bc);
            double eangle = reft.GetAngleInRadians(ec);
            double xangle = reft.GetAngleInRadians(x1);
            if (xangle > eangle)
            {
                xsect.Append(xend);
                return 1;
            }

            // Does it fall in the sector defined by this curve (NO tolerance allowed).
            PointGeometry xloc = PointGeometry.Create(x1);
            bool isxthis = Geom.IsInSector(xloc, c1, ab.First, ab.Second, 0.0);
            if (!isxthis)
            {
                xsect.Append(xend);
                return 1;
            }

            // Get the midpoint of the segment that connects the intersection to the matching end.
            IPosition midx = Position.CreateMidpoint(xend, x1);

            // If the midpoint does NOT graze the circle, we've got 2 distinct intersections.

            // 25-NOV-99: Be realistic about it (avoid meaningless sliver
            // polygons that are less than 0.1mm wide on the ground). Also,
            // the old way used 'centre' which may refer to r1 OR r2, so
            // you would have got the correct result only half of the time!
            // if ( fabs(midx.Distance(centre) - r1) > XYTOL ) {

            double rdiff = Geom.Distance(midx, c1) - r1;
            if (Math.Abs(rdiff) > 0.0001)
            {
                xsect.Append(xend);
                xsect.Append(x1);
                return 2;
            }

            // We've got a graze, but possibly one that can be ignored(!). To
            // understand the reasoning here, bear in mind that lines get cut
            // only so that network topology can be formed. To do that, 2
            // orientation points are obtained for the lines incident on xend.
//.........这里部分代码省略.........
开发者ID:steve-stanton,项目名称:backsight,代码行数:101,代码来源:IntersectionHelper.cs

示例3: CreateLinks


//.........这里部分代码省略.........
                    {
                        isRadial = false;
                        isCurveEnd = true;
                    }
                }
                else
                    centre = prevcen;

                // If the centre and radius were the same (or close enough),
                // define the radial bearing from the centre of the circle.
                // If the polygon is actually on the other side, reverse the
                // bearing so that it's directed INTO the polygon.

                if (isRadial)
                {
                    Debug.Assert(centre!=null);
                    bearing = Geom.BearingInRadians(centre, m_Begin);
                    angle = 0.0;
                    if (iscw  != isPolLeft)
                        bearing += Constants.PI;
                }
            }

            // If we're not dealing with a radial curve (or we have curves that
            // don't appear to be radial)
            if (!isRadial)
            {
                // Get the clockwise angle from the last position of the
                // preceding face to the first position after the start
                // of this face. Since info is held in a clockwise cycle
                // around the polygon, this will always give us the exterior
                // angle.
                Turn reference = new Turn(m_Begin, prev.TailReference);
                angle = reference.GetAngleInRadians(this.HeadReference);

                // Define the bearing to use for projecting the point. It's
                // in the middle of the angle, but projected into the polygon.
                bearing = reference.BearingInRadians + angle*0.5 + Constants.PI;
            }

            // Initialize the link at the start of the face
            List<PolygonLink> links = new List<PolygonLink>();
            PolygonLink link = new PolygonLink(beginPoint, isCurveEnd, isRadial, bearing, angle);
            links.Add(link);

            // Initialize links for any extra points
            if (m_ExtraPoints!=null)
            {
                // Intermediate points can never be curve ends
                isCurveEnd = false;

                // If the face is a curve, they're radial points
                isRadial = isThisCurve;

                // Note any curve info
                double radius;
                IPosition centre = null;
                bool iscw = false;

                if (isRadial)
                {
                    Debug.Assert(m_Divider.Line.LineGeometry is ICircularArcGeometry);
                    ICircularArcGeometry arc = (m_Divider.Line.LineGeometry as ICircularArcGeometry);
                    centre = arc.Circle.Center;
                    radius = arc.Circle.Radius;
                    iscw = arc.IsClockwise;
开发者ID:steve-stanton,项目名称:backsight,代码行数:67,代码来源:PolygonFace.cs

示例4: ArcIntersect

        /// <summary>
        /// Intersects 2 clockwise arcs that coincide with the perimeter of a circle.
        /// </summary>
        /// <param name="xsect">Intersection results.</param>
        /// <param name="circle">The circle the arcs coincide with</param>
        /// <param name="bc1">BC for 1st arc.</param>
        /// <param name="ec1">EC for 1st arc.</param>
        /// <param name="bc2">BC for 2nd arc.</param>
        /// <param name="ec2">EC for 2nd arc.</param>
        /// <returns>The number of intersections (0, 1, or 2). If non-zero, the intersections
        /// will be grazes.</returns>
        static uint ArcIntersect( IntersectionResult xsect
            , ICircleGeometry circle
            , IPointGeometry bc1
            , IPointGeometry ec1
            , IPointGeometry bc2
            , IPointGeometry ec2)
        {
            // Define the start of the clockwise arc as a reference line,
            // and get the clockwise angle to it's EC.
            Turn reft = new Turn(circle.Center, bc1);
            double sector = reft.GetAngleInRadians(ec1);

            // Where do the BC and EC of the 2nd curve fall with respect
            // to the 1st curve's arc sector?
            double bcang = reft.GetAngleInRadians(bc2);
            double ecang = reft.GetAngleInRadians(ec2);

            if (bcang<sector)
            {
                if (ecang<bcang)
                {
                    xsect.Append(bc2, ec1);
                    xsect.Append(bc1, ec2);
                    return 2;
                }

                if (ecang<sector)
                    xsect.Append(bc2, ec2);
                else
                    xsect.Append(bc2, ec1);

                return 1;
            }

            // The BC of the 2nd curve falls beyond the sector of the 1st ...
            // so we can't have any graze if the EC is even further on.
            if (ecang>bcang)
                return 0;

            // One graze ...

            if (ecang<sector)
                xsect.Append(bc1, ec2);
            else
                xsect.Append(bc1, ec1);

            return 1;
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:59,代码来源:IntersectionHelper.cs

示例5: ShowResult

        void ShowResult()
        {
            // If we have the first two points, get the distance between
            // them, format the result, and display it.
            if (m_Point1!=null && m_Point2!=null)
            {
                double metric = Geom.Distance(m_Point1, m_Point2);
                distance1TextBox.Text = Format(metric, m_Point1, m_Point2);
            }

            // Same for the second pair of points.
            if (m_Point2!=null && m_Point3!=null)
            {
                double metric = Geom.Distance(m_Point2, m_Point3);
                distance2TextBox.Text = Format(metric, m_Point2, m_Point3);
            }

            // If we have all 3 points, display the angle.
            if (m_Point1!=null && m_Point2!=null && m_Point3!=null)
            {
                // Get the clockwise angle.
                Turn reft = new Turn(m_Point2, m_Point1);
                double ang = reft.GetAngleInRadians(m_Point3);

                // Get the complement if we actually want it anti-clockwise.
                if (!m_Clockwise)
                    ang = Constants.PIMUL2 - ang;

                angleTextBox.Text = RadianValue.AsString(ang);
            }
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:31,代码来源:InverseDistanceAngleForm.cs

示例6: Intersect

        /// <summary>
        /// Intersects a line segment with the data describing a clockwise curve.
        /// </summary>
        /// <param name="result">The intersection results.</param>
        /// <param name="a">The start of the line segment</param>
        /// <param name="b">The end of the line segment</param>
        /// <param name="start">The start of the clockwise arc.</param>
        /// <param name="end">The end of the clockwise arc.</param>
        /// <param name="circle">The circle on which the arc lies.</param>
        /// <returns></returns>
        static uint Intersect( IntersectionResult result
            , IPointGeometry a
            , IPointGeometry b
            , IPointGeometry start
            , IPointGeometry end
            , ICircleGeometry circle)
        {
            // If the segment exactly meets either end of the curve, it gets handled seperately.
            if (a.IsCoincident(start) || a.IsCoincident(end))
                return EndIntersect(result, start, end, circle, a, b);

            if (b.IsCoincident(start) || b.IsCoincident(end))
                return EndIntersect(result, start, end, circle, b, a);

            // Get circle definition.
            IPointGeometry centre = circle.Center;
            double radius = circle.Radius;

            // Get up to 2 intersections with the circle.
            IPosition x1, x2;
            bool isGraze;
            uint nx = GetXCircle(a, b, centre, radius, out x1, out x2, out isGraze);

            // Return if no intersections with the circle.
            if (nx==0)
                return 0;

            // If an intersection is really close to the end of an arc, force it to be there.
            if (Geom.DistanceSquared(start, x1) < Constants.XYTOLSQ)
                x1 = start;
            else if (Geom.DistanceSquared(end, x1) < Constants.XYTOLSQ)
                x1 = end;

            if (nx==2)
            {
                if (Geom.DistanceSquared(start, x2) < Constants.XYTOLSQ)
                    x2 = start;
                else if (Geom.DistanceSquared(end, x2) < Constants.XYTOLSQ)
                    x2 = end;
            }

            // Determine whether the intersections fall within the sector
            // that's defined by the clockwise curve (grazes need a bit
            // more handling, so do that after we see how to do the non-
            // grazing case.

            if ( !isGraze )
            {
                PointGeometry xloc1 = PointGeometry.Create(x1);
                double lintol = Constants.XYTOL / radius;

                // If we only got one intersect, and it's out of sector, that's us done.
                if (nx==1)
                {
                    if (!BasicGeom.IsInSector(xloc1, centre, start, end, lintol))
                        return 0;

                    result.Append(x1);
                    return 1;
                }

                // Two intersections with the circle ...

                if (BasicGeom.IsInSector(xloc1, centre, start, end, lintol))
                    result.Append(x1);
                else
                    nx--;

                PointGeometry xloc2 = PointGeometry.Create(x2);

                if (BasicGeom.IsInSector(xloc2, centre, start, end, lintol))
                    result.Append(x2);
                else
                    nx--;

                return nx;
            }

            // That leaves us with the case where this segment grazes the
            // circle. GetXCircle is always supposed to return nx==2 in that
            // case (they're also supposed to be arranged in the same
            // direction as this segment).
            Debug.Assert(nx==2);

            // Get the clockwise angle subtended by the circular arc. Add
            // on a tiny bit to cover numerical comparison problems.
            Turn reft = new Turn(centre, start);
            double maxangle = reft.GetAngleInRadians(end) + Constants.TINY;

            // Get the clockwise angles to both intersections.
//.........这里部分代码省略.........
开发者ID:steve-stanton,项目名称:backsight,代码行数:101,代码来源:IntersectionHelper.cs

示例7: GetSweepAngleInRadians

 public static double GetSweepAngleInRadians(ICircularArcGeometry g)
 {
     IPosition f = g.First;
     IPosition s = g.Second;
     Turn t = new Turn(g.Circle.Center, f);
     return t.GetAngleInRadians(s);
 }
开发者ID:steve-stanton,项目名称:backsight,代码行数:7,代码来源:CircularArcGeometry.cs

示例8: GetApproximation

        /// <summary>
        /// Generates an approximation of a circular arc.
        /// </summary>
        /// <param name="tol">The maximum chord-to-circumference distance.</param>
        /// <returns></returns>
        public static IPointGeometry[] GetApproximation(ICircularArcGeometry g, ILength tol)
        {
            // Get info about the circle the curve lies on.
            IPosition center = g.Circle.Center;
            double radius = g.Circle.Radius;

            // Determine the change in bearing which will satisfy the specified tolerance
            // (if no tolerance has been specified, arbitrarily use a tolerance of 1mm on the ground).
            double tolm = (tol.Meters > Double.Epsilon ? tol.Meters : 0.001);
            double dbear = Math.Acos((radius-tolm)/radius);

            IPointGeometry start = g.BC;
            IPointGeometry end = g.EC;
            bool iscw = g.IsClockwise;

            // Get the total angle subtended by the curve.
            Turn reft = new Turn(center, start);
            double totang = reft.GetAngleInRadians(end); // clockwise
            if (!iscw)
                totang = MathConstants.PIMUL2 - totang;

            // Figure out how many positions we'll generate
            int nv = (int)(totang/dbear); // truncate
            Debug.Assert(nv>=0);

            // Handle special case of very short arc.
            if (nv==0)
                return new IPointGeometry[] { start, end };

            // Sign the delta-bearing the right way.
            if (!iscw)
                dbear = -dbear;

            // Get the initial bearing to the first position along the curve.
            double curbear = reft.BearingInRadians + dbear;

            // Append positions along the length of the curve.
            List<IPointGeometry> result = new List<IPointGeometry>(nv);
            result.Add(start);

            for (int i=0; i<nv; i++, curbear+=dbear)
            {
                IPosition p = BasicGeom.Polar(center, curbear, radius);
                result.Add(PositionGeometry.Create(p));
            }

            result.Add(end);
            return result.ToArray();
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:54,代码来源:CircularArcGeometry.cs

示例9: ShowResult

        internal virtual void ShowResult()
        {
            // If we have two points, get the distance between them,
            // format the result, and display it.
            if (m_Point1!=null && m_Point2!=null && m_CommCir!=null)
            {
                // It's conceivable that the two points share more than
                // one common circle. For now, just pick off the first
                // common circle and use that.
                Circle circle = m_CommCir[0];

                // Get the centre of the circle.
                IPosition c = circle.Center;

                // Get the clockwise angle from point 1 to point 2.
                Turn reft = new Turn(c, m_Point1);
                double angle = reft.GetAngleInRadians(m_Point2);
                bool iscw = true;

                // Make sure the angle is consistent with whether we want
                // the short or the long arc distance.
                bool isshort = (angle < Constants.PI);
                if (isshort != m_WantShort)
                {
                    angle = Constants.PIMUL2 - angle;
                    iscw = false;
                }

                // Get the arc distance and display it.
                double metric = angle * circle.Radius;
                distanceTextBox.Text = Format(metric, m_Point1, m_Point2);

                // Remember the geometry that corresponds to the displayed distance (this
                // will be drawn when the controller periodically calls the Draw method).
                m_CurrentDistanceArc = new CircularArcGeometry(circle, m_Point1, m_Point2, iscw);
            }
            else
            {
                distanceTextBox.Text = "<no distance>";
                m_CurrentDistanceArc = null;
            }
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:42,代码来源:InverseArcDistanceForm.cs

示例10: Execute

        /// <summary>
        /// Creates a new circular arc.
        /// </summary>
        /// <param name="start">The point at the start of the new arc.</param>
        /// <param name="end">The point at the end of the new arc.</param>
        /// <param name="circle">The circle that the new arc should sit on.</param>
        /// <param name="isShortArc">True if the new arc refers to the short arc. False
        /// if it's a long arc (i.e. greater than half the circumference of the circle).</param>
        internal void Execute(PointFeature start, PointFeature end, Circle circle, bool isShortArc)
        {
            // Disallow an attempt to add a null line.
            if (start.Geometry.IsCoincident(end.Geometry))
                throw new Exception("NewArcOperation.Execute - Attempt to add null line.");

            // Figure out whether the arc should go clockwise or not.
            IPointGeometry centre = circle.Center;

            // Get the clockwise angle from the start to the end.
            Turn sturn = new Turn(centre, start);
            double angle = sturn.GetAngleInRadians(end);

            // Figure out which direction the curve should go, depending
            // on whether the user wants the short arc or the long one.
            bool iscw;
            if (angle < Constants.PI)
                iscw = isShortArc;
            else
                iscw = !isShortArc;

            // Add the new arc with default line entity type (this will
            // cross-reference the circle to the arc that gets created).
            CadastralMapModel map = CadastralMapModel.Current;
            LineFeature newLine = map.AddCircularArc(circle, start, end, iscw, map.DefaultLineType, this);
            base.SetNewLine(newLine);

            // Peform standard completion steps
            Complete();
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:38,代码来源:NewArcOperation.cs

示例11: SetSortValues

        /// <summary>
        /// Assigns sort values to the supplied intersections (each sort value
        /// indicates the distance from the start of this line).
        /// </summary>
        /// <param name="data">The intersection data to update</param>
        internal override void SetSortValues(List<IntersectionData> data)
        {
            // Get the position of the centre of the circle for this curve,
            // along with the stored radius.
            IPosition centre = m_Circle.Center;
            double radius = m_Circle.Radius;

            // Define reference directions to the start and end of curve,
            // ordered clockwise.
            Turn start = new Turn(centre, First);
            Turn end = new Turn(centre, Second);

            // If we are dealing with a counter-clockwise curve, note
            // the total length of the curve. This is because the lengths
            // we will be calculating below are reckoned in a clockwise
            // direction.
            double crvlen = 0.0;
            if (!m_IsClockwise)
                crvlen = this.Length.Meters;

            // For each intersection, get the angle with respect to the start of the curve.

            double angle;		// Angle of the intersection.
            double angle2;		// Angle of 2nd intersection.

            // Figure out an angular tolerance for comparing bearings to the curve ends.
            //double angtol = Constants.XYTOL/radius;
            double angtol = 0.002/radius;

            foreach (IntersectionData xd in data)
            {
                // Get the angle to the first intersection (calculate with
                // respect to the end of curve, to check for an intersection
                // that is REAL close to the end).

                IPosition xpos = xd.P1;
                double xi = xpos.X;
                double yi = xpos.Y;

                if (end.GetAngleInRadians(xpos, angtol) < Constants.TINY)
                    angle = start.GetAngle(end);
                else
                    angle = start.GetAngleInRadians(xpos, angtol);

                // If we have a graze, process the 2nd intersection too.
                // If it's closer than the distance we already have, use
                // the second intersection as the sort value, and treat
                // it subsequently as the first intersection.

                if (xd.IsGraze)
                {
                    xpos = xd.P2;
                    xi = xpos.X;
                    yi = xpos.Y;

                    if (end.GetAngleInRadians(xpos, angtol) < Constants.TINY)
                        angle2 = start.GetAngle(end);
                    else
                        angle2 = start.GetAngleInRadians(xpos, angtol);

                    if (m_IsClockwise)
                    {
                        if (angle2 < angle)
                        {
                            xd.Reverse();
                            angle = angle2;
                        }
                    }
                    else
                    {
                        if (angle < angle2)
                        {
                            xd.Reverse();
                            angle = angle2;
                        }
                    }
                }

                // Set the sort value. For counterclockwise curves, remember
                // that the length is from the wrong end.
                double dset = angle*radius;
                if (dset < Constants.TINY)
                    dset = 0.0;
                if (!m_IsClockwise)
                    dset = crvlen-dset;
                xd.SortValue = dset;
            }
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:93,代码来源:ArcGeometry.cs


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