本文整理汇总了C#中Jitter2D.LinearMath.JVector.Length方法的典型用法代码示例。如果您正苦于以下问题:C# JVector.Length方法的具体用法?C# JVector.Length怎么用?C# JVector.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jitter2D.LinearMath.JVector
的用法示例。
在下文中一共展示了JVector.Length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Detect
//.........这里部分代码省略.........
if (JVector.Dot(ref v1, ref normal) <= 0.0f) return false;
// v2 = support perpendicular to v1,v0
normal = OutsidePortal(v1, v0);
JVector.Negate(ref normal, out mn);
SupportMapTransformed(support1, ref orientation1, ref position1, ref mn, out v21);
SupportMapTransformed(support2, ref orientation2, ref position2, ref normal, out v22);
JVector.Subtract(ref v22, ref v21, out v2);
//LD.Draw(Conversion.ToXNAVector2(v1), Conversion.ToXNAVector2(v0), Color.Blue);
//LD.Draw(Conversion.ToXNAVector2(v2), Conversion.ToXNAVector2(v0), Color.Blue);
if (JVector.Dot(ref v2, ref normal) <= 0.0f) return false;
// phase two: portal refinement
int maxIterations = 0;
while (true)
{
// find normal direction
if (!IntersectPortal(v0, v2, v1))
normal = InsidePortal(v2, v1);
else
// origin ray crosses the portal
normal = OutsidePortal(v2, v1);
// obtain the next support point
JVector.Negate(ref normal, out mn);
SupportMapTransformed(support1, ref orientation1, ref position1, ref mn, out v31);
SupportMapTransformed(support2, ref orientation2, ref position2, ref normal, out v32);
JVector.Subtract(ref v32, ref v31, out v3);
//LD.Draw(Conversion.ToXNAVector2(v3), Conversion.ToXNAVector2(v0), Color.Green);
if (JVector.Dot(v3, normal) <= 0)
{
JVector ab = v3 - v2;
float t = -(JVector.Dot(v2, ab)) / (JVector.Dot(ab, ab));
normal = (v2 + (t * ab));
return false;
}
// Portal lies on the outside edge of the Minkowski Hull.
// Return contact information
if (JVector.Dot((v3 - v2), normal) <= CollideEpsilon || ++maxIterations > MaximumIterations)
{
JVector ab = v2 - v1;
float t = JVector.Dot(JVector.Negate(v1), ab);
if (t <= 0.0f)
{
t = 0.0f;
normal = v1;
}
else
{
float denom = JVector.Dot(ab, ab);
if (t >= denom)
{
normal = v2;
t = 1.0f;
}
else
{
t /= denom;
normal = v1 + t * ab;
}
}
float s = 1 - t;
point = s * v11 + t * v21;
var point2 = s * v12 + t * v22;
// this causes a sq root = bad!
penetration = normal.Length();
normal.Normalize();
return true;
}
// if origin is inside (v1, v0, v3), refine portal
if (OriginInTriangle(v0, v1, v3))
{
v2 = v3;
v21 = v31;
v22 = v32;
continue;
}
// if origin is inside (v3, v0, v2), refine portal
else if (OriginInTriangle(v0, v2, v3))
{
v1 = v3;
v11 = v31;
v12 = v32;
continue;
}
return false;
}
}