本文整理汇总了C#中Vertices.isCounterClockWise方法的典型用法代码示例。如果您正苦于以下问题:C# Vertices.isCounterClockWise方法的具体用法?C# Vertices.isCounterClockWise怎么用?C# Vertices.isCounterClockWise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices.isCounterClockWise方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvexPartition
/// <summary>
/// Decompose the polygon into several smaller non-concave polygon.
/// If the polygon is already convex, it will return the original polygon, unless it is over Settings.MaxPolygonVertices.
/// </summary>
public static List<Vertices> ConvexPartition(Vertices vertices)
{
Debug.Assert(vertices.Count > 3);
Debug.Assert(vertices.isCounterClockWise());
return TriangulatePolygon(vertices);
}
示例2: ConvexPartition
//box2D rev 32 - for details, see http://www.box2d.org/forum/viewtopic.php?f=4&t=83&start=50
/// <summary>
/// Decompose the polygon into several smaller non-concave polygon.
/// Each resulting polygon will have no more than Settings.MaxPolygonVertices vertices.
/// </summary>
/// <param name="vertices">The vertices.</param>
/// <param name="tolerance">The tolerance.</param>
public static List<Vertices> ConvexPartition(Vertices vertices, float tolerance = 0.001f)
{
Debug.Assert(vertices.Count > 3);
Debug.Assert(!vertices.isCounterClockWise());
return TriangulatePolygon(vertices, tolerance);
}
示例3: ConvexPartition
/// <summary>
/// Decompose the polygon into triangles.
///
/// Properties:
/// - Only works on counter clockwise polygons
///
/// </summary>
/// <param name="vertices">The list of points describing the polygon</param>
public static List<Vertices> ConvexPartition(Vertices vertices)
{
Debug.Assert(vertices.Count > 3);
Debug.Assert(vertices.isCounterClockWise());
int[] polygon = new int[vertices.Count];
for (int v = 0; v < vertices.Count; v++)
polygon[v] = v;
int nv = vertices.Count;
// Remove nv-2 Vertices, creating 1 triangle every time
int count = 2 * nv; /* error detection */
List<Vertices> result = new List<Vertices>();
for (int v = nv - 1; nv > 2; )
{
// If we loop, it is probably a non-simple polygon
if (0 >= (count--))
{
// Triangulate: ERROR - probable bad polygon!
return new List<Vertices>();
}
// Three consecutive vertices in current polygon, <u,v,w>
int u = v;
if (nv <= u)
u = 0; // Previous
v = u + 1;
if (nv <= v)
v = 0; // New v
int w = v + 1;
if (nv <= w)
w = 0; // Next
_tmpA = vertices[polygon[u]];
_tmpB = vertices[polygon[v]];
_tmpC = vertices[polygon[w]];
if (Snip(vertices, u, v, w, nv, polygon))
{
int s, t;
// Output Triangle
Vertices triangle = new Vertices(3);
triangle.Add(_tmpA);
triangle.Add(_tmpB);
triangle.Add(_tmpC);
result.Add(triangle);
// Remove v from remaining polygon
for (s = v, t = v + 1; t < nv; s++, t++)
{
polygon[s] = polygon[t];
}
nv--;
// Reset error detection counter
count = 2 * nv;
}
}
return result;
}
示例4: convexPartition
public static List<Vertices> convexPartition( Vertices vertices, TriangulationAlgorithm algorithm, bool discardAndFixInvalid = true, float tolerance = 0.001f )
{
if( vertices.Count <= 3 )
return new List<Vertices> { vertices };
List<Vertices> results = null;
switch( algorithm )
{
case TriangulationAlgorithm.Earclip:
if( Settings.skipSanityChecks )
{
Debug.Assert( !vertices.isCounterClockWise(), "The Earclip algorithm expects the polygon to be clockwise." );
results = EarclipDecomposer.ConvexPartition( vertices, tolerance );
}
else
{
if( vertices.isCounterClockWise() )
{
var temp = new Vertices( vertices );
temp.Reverse();
results = EarclipDecomposer.ConvexPartition( temp, tolerance );
}
else
{
results = EarclipDecomposer.ConvexPartition( vertices, tolerance );
}
}
break;
case TriangulationAlgorithm.Bayazit:
if( Settings.skipSanityChecks )
{
Debug.Assert( vertices.isCounterClockWise(), "The polygon is not counter clockwise. This is needed for Bayazit to work correctly." );
results = BayazitDecomposer.ConvexPartition( vertices );
}
else
{
if( !vertices.isCounterClockWise() )
{
var temp = new Vertices( vertices );
temp.Reverse();
results = BayazitDecomposer.ConvexPartition( temp );
}
else
{
results = BayazitDecomposer.ConvexPartition( vertices );
}
}
break;
case TriangulationAlgorithm.Flipcode:
if( Settings.skipSanityChecks )
{
Debug.Assert( vertices.isCounterClockWise(), "The polygon is not counter clockwise. This is needed for Bayazit to work correctly." );
results = FlipcodeDecomposer.ConvexPartition( vertices );
}
else
{
if( !vertices.isCounterClockWise() )
{
var temp = new Vertices( vertices );
temp.Reverse();
results = FlipcodeDecomposer.ConvexPartition( temp );
}
else
{
results = FlipcodeDecomposer.ConvexPartition( vertices );
}
}
break;
case TriangulationAlgorithm.Seidel:
results = SeidelDecomposer.ConvexPartition( vertices, tolerance );
break;
case TriangulationAlgorithm.SeidelTrapezoids:
results = SeidelDecomposer.ConvexPartitionTrapezoid( vertices, tolerance );
break;
case TriangulationAlgorithm.Delauny:
results = CDTDecomposer.ConvexPartition( vertices );
break;
default:
throw new ArgumentOutOfRangeException( nameof( algorithm ) );
}
if( discardAndFixInvalid )
{
for( int i = results.Count - 1; i >= 0; i-- )
{
var polygon = results[i];
if( !validatePolygon( polygon ) )
results.RemoveAt( i );
}
}
return results;
}