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


C# Point3D.DistanceTo方法代码示例

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


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

示例1: GetNearest_PointOnRay

 public void GetNearest_PointOnRay()
 {
     var ray = new Ray3D(new Point3D(0, 0, 0), new Vector3D(1, 2, 3));
     var p0 = new Point3D(0.1, 0.2, 0.3);
     var p = ray.GetNearest(p0);
     Assert.AreEqual(0, p0.DistanceTo(p), 1e-12);
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:7,代码来源:Ray3DTests.cs

示例2: PlaneIntersection_RayThroughPlaneOrigin

 public void PlaneIntersection_RayThroughPlaneOrigin()
 {
     var ray = new Ray3D(new Point3D(1, 2, 3), new Vector3D(-1, -2, -3));
     Point3D p;
     Assert.IsTrue(ray.PlaneIntersection(new Point3D(0, 0, 0), new Vector3D(1, 1, 1), out p));
     var pe = new Point3D(0, 0, 0);
     Assert.AreEqual(0, pe.DistanceTo(p), 1e-12);
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:8,代码来源:Ray3DTests.cs

示例3: GetCameraDistance

 /// <summary>
 /// Gets the distance from the camera for the specified visual.
 /// </summary>
 /// <param name="c">
 /// The visual.
 /// </param>
 /// <param name="cameraPos">
 /// The camera position.
 /// </param>
 /// <param name="transform">
 /// The total transform of the visual.
 /// </param>
 /// <returns>
 /// The camera distance.
 /// </returns>
 private double GetCameraDistance(Visual3D c, Point3D cameraPos, Transform3D transform)
 {
     var bounds = Visual3DHelper.FindBounds(c, transform);
     switch (this.Method)
     {
         case SortingMethod.BoundingBoxCenter:
             var mid = new Point3D(
                 bounds.X + bounds.SizeX * 0.5, bounds.Y + bounds.SizeY * 0.5, bounds.Z + bounds.SizeZ * 0.5);
             return (mid - cameraPos).LengthSquared;
         case SortingMethod.BoundingBoxCorners:
             double d = double.MaxValue;
             d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y, bounds.Z)));
             d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X + bounds.SizeX, bounds.Y, bounds.Z)));
             d = Math.Min(
                 d, cameraPos.DistanceTo(new Point3D(bounds.X + bounds.SizeX, bounds.Y + bounds.SizeY, bounds.Z)));
             d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y + bounds.SizeY, bounds.Z)));
             d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y, bounds.Z + bounds.SizeZ)));
             d = Math.Min(
                 d, cameraPos.DistanceTo(new Point3D(bounds.X + bounds.SizeX, bounds.Y, bounds.Z + bounds.SizeZ)));
             d = Math.Min(
                 d,
                 cameraPos.DistanceTo(
                     new Point3D(bounds.X + bounds.SizeX, bounds.Y + bounds.SizeY, bounds.Z + bounds.SizeZ)));
             d = Math.Min(
                 d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y + bounds.SizeY, bounds.Z + bounds.SizeZ)));
             return d;
         default:
             var boundingSphere = BoundingSphere.CreateFromRect3D(bounds);
             return boundingSphere.DistanceFrom(cameraPos);
     }
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:46,代码来源:SortingVisual3D.cs

示例4: DistanceFrom

 /// <summary>
 /// Calculates the distance from a point to the nearest point on the sphere surface.
 /// </summary>
 /// <param name="point">
 /// The point.
 /// </param>
 /// <returns>
 /// The distance.
 /// </returns>
 public double DistanceFrom(Point3D point)
 {
     return point.DistanceTo(this.center) - this.radius;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:13,代码来源:BoundingSphere.cs


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