本文整理汇总了C#中Engine.Vector.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Normalize方法的具体用法?C# Vector.Normalize怎么用?C# Vector.Normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine.Vector
的用法示例。
在下文中一共展示了Vector.Normalize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildNormals
/// <summary>
/// Build the edge normals, and updates the boundaries (Left,Right,...).
/// Assumes that all vertices are in the vertices list, and that some arbitrary items has been added to the edgeNormals list.
/// </summary>
protected void BuildNormals()
{
edgeNormals.Clear();
MoveTo(center.X, center.Y);
edgeNormals = new List<Vector>(vertices.Count - (vertices.Count <= 2 ? 1 : 0));
left = 0; bottom = 0;
right = 0; top = 0;
for (int i = 0; i < edgeNormals.Capacity; i++)
{
Vector edge, normal;
edge = vertices[i == vertices.Count - 1 ? 0 : i+1] - vertices[i];
normal = new Vector(-edge.Y, edge.X);
normal.Normalize();
edgeNormals.Add(normal);
//Update outer boundaries
if (vertices[i].X < Left) left = i;
if (vertices[i].X > Right) right = i;
if (vertices[i].Y < Bottom) bottom = i;
if (vertices[i].Y > Top) top = i;
}
for (int i = edgeNormals.Count; i < vertices.Count; i++)
{
//Update outer boundaries
if (vertices[i].X < Left) left = i;
if (vertices[i].X > Right) right = i;
if (vertices[i].Y < Bottom) bottom = i;
if (vertices[i].Y > Top) top = i;
}
}