本文整理汇总了C#中System.Vector2.Normalise方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.Normalise方法的具体用法?C# Vector2.Normalise怎么用?C# Vector2.Normalise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector2
的用法示例。
在下文中一共展示了Vector2.Normalise方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Normalize
/// <summary>
///
/// </summary>
/// <param name="ret"></param>
/// <returns></returns>
public static float Normalize( Vector2 ret)
{
//float fLength = Utility.Sqrt(ret.x * ret.x + ret.y * ret.y);
//// Will also work for zero-sized vectors, but will change nothing
//if (fLength > 1e-08)
//{
// float fInvLength = 1.0f / fLength;
// ret.x *= fInvLength;
// ret.y *= fInvLength;
//}
//return fLength;
return ret.Normalise();
}
示例2: modify
//--------------------------------------------------------------
public void modify() {
if (mInputTriangleBuffer == null)
OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Input triangle buffer must be set", "__FUNCTION__");
;
//for (List<TriangleBuffer.Vertex>.Enumerator it = mInputTriangleBuffer.getVertices().begin(); it != mInputTriangleBuffer.getVertices().end(); ++it)
foreach (var it in mInputTriangleBuffer.getVertices()) {
Vector3 input = it.mPosition.NormalisedCopy;
Vector3 v = new Vector3();
Radian r = new Radian();
if (input.y > 0)
Vector3.UNIT_Y.GetRotationTo(input).ToAngleAxis(out r, out v);
else
Vector3.NEGATIVE_UNIT_Y.GetRotationTo(input).ToAngleAxis(out r, out v);
Vector2 v2 = new Vector2(input.x, input.z);
v2.Normalise();
Vector2 uv = new Vector2(0.5f, 0.5f) + 0.5f * (r / Math.HALF_PI).ValueRadians * v2;
if (input.y > 0)
it.mUV = Utils.reframe(mTextureRectangleTop, uv);
else
it.mUV = Utils.reframe(mTextureRectangleBottom, uv);
}
}