本文整理汇总了C#中System.Numerics.Vector3.Length方法的典型用法代码示例。如果您正苦于以下问题:C# System.Numerics.Vector3.Length方法的具体用法?C# System.Numerics.Vector3.Length怎么用?C# System.Numerics.Vector3.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Numerics.Vector3
的用法示例。
在下文中一共展示了System.Numerics.Vector3.Length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBoundingBox
private void GetBoundingBox(ref Matrix3x3 o, out BoundingBox boundingBox)
{
#if !WINDOWS
boundingBox = new BoundingBox();
#endif
//Sample the local directions from the matrix, implicitly transposed.
var rightDirection = new System.Numerics.Vector3(o.M11, o.M21, o.M31);
var upDirection = new System.Numerics.Vector3(o.M12, o.M22, o.M32);
var backDirection = new System.Numerics.Vector3(o.M13, o.M23, o.M33);
int right = 0, left = 0, up = 0, down = 0, backward = 0, forward = 0;
float minX = float.MaxValue, maxX = -float.MaxValue, minY = float.MaxValue, maxY = -float.MaxValue, minZ = float.MaxValue, maxZ = -float.MaxValue;
for (int i = 0; i < hullVertices.Count; i++)
{
float dotX, dotY, dotZ;
Vector3Ex.Dot(ref rightDirection, ref hullVertices.Elements[i], out dotX);
Vector3Ex.Dot(ref upDirection, ref hullVertices.Elements[i], out dotY);
Vector3Ex.Dot(ref backDirection, ref hullVertices.Elements[i], out dotZ);
if (dotX < minX)
{
minX = dotX;
left = i;
}
if (dotX > maxX)
{
maxX = dotX;
right = i;
}
if (dotY < minY)
{
minY = dotY;
down = i;
}
if (dotY > maxY)
{
maxY = dotY;
up = i;
}
if (dotZ < minZ)
{
minZ = dotZ;
forward = i;
}
if (dotZ > maxZ)
{
maxZ = dotZ;
backward = i;
}
}
//Incorporate the collision margin.
Vector3Ex.Multiply(ref rightDirection, meshCollisionMargin / (float)Math.Sqrt(rightDirection.Length()), out rightDirection);
Vector3Ex.Multiply(ref upDirection, meshCollisionMargin / (float)Math.Sqrt(upDirection.Length()), out upDirection);
Vector3Ex.Multiply(ref backDirection, meshCollisionMargin / (float)Math.Sqrt(backDirection.Length()), out backDirection);
var rightElement = hullVertices.Elements[right];
var leftElement = hullVertices.Elements[left];
var upElement = hullVertices.Elements[up];
var downElement = hullVertices.Elements[down];
var backwardElement = hullVertices.Elements[backward];
var forwardElement = hullVertices.Elements[forward];
Vector3Ex.Add(ref rightElement, ref rightDirection, out rightElement);
Vector3Ex.Subtract(ref leftElement, ref rightDirection, out leftElement);
Vector3Ex.Add(ref upElement, ref upDirection, out upElement);
Vector3Ex.Subtract(ref downElement, ref upDirection, out downElement);
Vector3Ex.Add(ref backwardElement, ref backDirection, out backwardElement);
Vector3Ex.Subtract(ref forwardElement, ref backDirection, out forwardElement);
//Rather than transforming each axis independently (and doing three times as many operations as required), just get the 6 required values directly.
TransformLocalExtremePoints(ref rightElement, ref upElement, ref backwardElement, ref o, out boundingBox.Max);
TransformLocalExtremePoints(ref leftElement, ref downElement, ref forwardElement, ref o, out boundingBox.Min);
}
示例2: Kick
public void Kick(Vector3 dir)
{
Speed = (dir.Length());
RegenerateOrthonormalBasis(dir);
}