本文整理匯總了C#中Sharp3D.Math.Core.Vector3D.Normalize方法的典型用法代碼示例。如果您正苦於以下問題:C# Vector3D.Normalize方法的具體用法?C# Vector3D.Normalize怎麽用?C# Vector3D.Normalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sharp3D.Math.Core.Vector3D
的用法示例。
在下文中一共展示了Vector3D.Normalize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ToHalfAxis
public static HAxis ToHalfAxis(Vector3D v)
{
const double eps = 1.0E-03;
v.Normalize();
if (Math.Abs(Vector3D.DotProduct(v, -Vector3D.XAxis) - 1) < eps)
return HAxis.AXIS_X_N;
else if (Math.Abs(Vector3D.DotProduct(v, Vector3D.XAxis) - 1) < eps)
return HAxis.AXIS_X_P;
else if (Math.Abs(Vector3D.DotProduct(v, -Vector3D.YAxis) - 1) < eps)
return HAxis.AXIS_Y_N;
else if (Math.Abs(Vector3D.DotProduct(v, Vector3D.YAxis) - 1) < eps)
return HAxis.AXIS_Y_P;
else if (Math.Abs(Vector3D.DotProduct(v, -Vector3D.ZAxis) - 1) < eps)
return HAxis.AXIS_Z_N;
else
return HAxis.AXIS_Z_P;
}
示例2: Rotation
/// <summary>
/// Creates a rotation around a given axis
/// </summary>
/// <param name="u">A <see cref="Vector3D"/> that defines the rotation axis direction</param>
/// <param name="angle">A double angle value in degree</param>
/// <returns>A <see cref="Transform3D"/> object</returns>
public static Transform3D Rotation(Vector3D u, double angle)
{
u.Normalize();
double angleRad = angle * System.Math.PI;
double c = System.Math.Cos(angleRad);
double s = System.Math.Sin(angleRad);
Matrix4D m = Matrix4D.Identity;
m.M11 = u.X * u.X + (1.0 - u.X * u.X) * c;
m.M12 = u.X * u.Y * (1.0 - c) - u.Z * s;
m.M13 = u.X * u.Z * (1.0 - c) + u.Y * s;
m.M21 = u.Y * u.X * (1.0 - c) + u.Z * s;
m.M22 = u.Y * u.Y * (1.0 - u.Y * u.Y) * c;
m.M21 = u.Y * u.Z * (1.0 - c) - u.X * s;
m.M31 = u.Z * u.X * (1.0 - c) + u.Y * s;
m.M32 = u.Z * u.Y * (1.0 - c) + u.X * s;
m.M33 = u.Z * u.Z * (1.0 - u.Z * u.Z) * c;
return new Transform3D(m);
}