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


C# Point.Reset方法代码示例

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


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

示例1: PointOnBearing

 public override Point PointOnBearing(Point from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse)
 {
     if (distDEG == 0)
     {
         if (reuse == null)
             return from;
         reuse.Reset(from.GetX(), from.GetY());
         return reuse;
     }
     double bearingRAD = DistanceUtils.ToRadians(bearingDEG);
     double x = from.GetX() + Math.Sin(bearingRAD)*distDEG;
     double y = from.GetY() + Math.Cos(bearingRAD)*distDEG;
     if (reuse == null)
     {
         return ctx.MakePoint(x, y);
     }
     else
     {
         reuse.Reset(x, y);
         return reuse;
     }
 }
开发者ID:h0st1le,项目名称:Spatial4n,代码行数:22,代码来源:CartesianDistCalc.cs

示例2: PointOnBearingRAD

        /**
         * Given a start point (startLat, startLon) and a bearing on a sphere of radius <i>sphereRadius</i>, return the destination point.
         *
         *
         * @param startLat The starting point latitude, in radians
         * @param startLon The starting point longitude, in radians
         * @param distanceRAD The distance to travel along the bearing in radians.
         * @param bearingRAD The bearing, in radians.  North is a 0, moving clockwise till radians(360).
         * @param result A preallocated array to hold the results.  If null, a new one is constructed.
         * @return The destination point, in radians.  First entry is latitude, second is longitude
         */
        public static Point PointOnBearingRAD(double startLat, double startLon, double distanceRAD, double bearingRAD, SpatialContext ctx, Point reuse)
        {
            /*
               lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ))
             lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2))
              */
            double cosAngDist = Math.Cos(distanceRAD);
            double cosStartLat = Math.Cos(startLat);
            double sinAngDist = Math.Sin(distanceRAD);
            double sinStartLat = Math.Sin(startLat);
            double lat2 = Math.Asin(sinStartLat*cosAngDist +
                                    cosStartLat*sinAngDist*Math.Cos(bearingRAD));
            double lon2 = startLon + Math.Atan2(Math.Sin(bearingRAD)*sinAngDist*cosStartLat,
                                                cosAngDist - sinStartLat*Math.Sin(lat2));

            // normalize lon first
            if (lon2 > DEG_180_AS_RADS)
            {
                lon2 = -1.0*(DEG_180_AS_RADS - (lon2 - DEG_180_AS_RADS));
            }
            else if (lon2 < -DEG_180_AS_RADS)
            {
                lon2 = (lon2 + DEG_180_AS_RADS) + DEG_180_AS_RADS;
            }

            // normalize lat - could flip poles
            if (lat2 > DEG_90_AS_RADS)
            {
                lat2 = DEG_90_AS_RADS - (lat2 - DEG_90_AS_RADS);
                if (lon2 < 0)
                {
                    lon2 = lon2 + DEG_180_AS_RADS;
                }
                else
                {
                    lon2 = lon2 - DEG_180_AS_RADS;
                }
            }
            else if (lat2 < -DEG_90_AS_RADS)
            {
                lat2 = -DEG_90_AS_RADS - (lat2 + DEG_90_AS_RADS);
                if (lon2 < 0)
                {
                    lon2 = lon2 + DEG_180_AS_RADS;
                }
                else
                {
                    lon2 = lon2 - DEG_180_AS_RADS;
                }
            }

            if (reuse == null)
            {
                return ctx.MakePoint(lon2, lat2);
            }
            else
            {
                reuse.Reset(lon2, lat2); //x y
                return reuse;
            }
        }
开发者ID:h0st1le,项目名称:Spatial4n,代码行数:72,代码来源:DistanceUtils.cs

示例3: PointOnBearing

 public override Point PointOnBearing(Point @from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse)
 {
     if (distDEG == 0)
     {
         if (reuse == null)
             return from;
         reuse.Reset(from.GetX(), from.GetY());
         return reuse;
     }
     Point result = DistanceUtils.PointOnBearingRAD(
         DistanceUtils.ToRadians(from.GetY()), DistanceUtils.ToRadians(from.GetX()),
         DistanceUtils.ToRadians(distDEG),
         DistanceUtils.ToRadians(bearingDEG), ctx, reuse);//output result is in radians
     result.Reset(DistanceUtils.ToDegrees(result.GetX()), DistanceUtils.ToDegrees(result.GetY()));
     return result;
 }
开发者ID:h0st1le,项目名称:Spatial4n,代码行数:16,代码来源:GeodesicSphereDistCalc.cs


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