本文整理汇总了C#中CryEngine.Vec3.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Vec3.Normalize方法的具体用法?C# Vec3.Normalize怎么用?C# Vec3.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CryEngine.Vec3
的用法示例。
在下文中一共展示了Vec3.Normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Normalize_Vec3_LengthIsEqualToOne
public void Normalize_Vec3_LengthIsEqualToOne()
{
Vec3 v = new Vec3(26, 23, 135);
v.Normalize();
Assert.IsTrue(v.Length == 1);
}
示例2: ClosestPointSphereSphere
/// <summary>
/// Determines the closest point between a <see cref="CryEngine.BoundingSphere"/> and a <see cref="CryEngine.BoundingSphere"/>.
/// </summary>
/// <param name="sphere1">The first sphere to test.</param>
/// <param name="sphere2">The second sphere to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects;
/// or, if the point is directly in the center of the sphere, contains <see cref="CryEngine.Vec3"/>.</param>
/// <remarks>
/// If the two spheres are overlapping, but not directly ontop of each other, the closest point
/// is the 'closest' point of intersection. This can also be considered is the deepest point of
/// intersection.
/// </remarks>
public static void ClosestPointSphereSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2, out Vec3 result)
{
// Source: Jorgy343
// Reference: None
// Get the unit direction from the first sphere's center to the second sphere's center.
result = sphere2.Center - sphere1.Center;
result.Normalize();
// Multiply the unit direction by the first sphere's radius to get a vector
// the length of the first sphere.
result *= sphere1.Radius;
// Add the first sphere's center to the direction to get a point on the first sphere.
result += sphere1.Center;
}