本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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;
}