mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 18:58:47 +00:00
refactor: remove Polyhedron.IsConvex
This commit is contained in:
parent
9417ee6be1
commit
15d0f93f8b
@ -55,37 +55,6 @@ public class Polyhedron : IEquatable<Polyhedron>
|
||||
get => new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether this polyhedron is convex.
|
||||
/// </summary>
|
||||
/// <value><see langword="true" /> if this polyhedron is convex; otherwise, <see langword="false" />.</value>
|
||||
public bool IsConvex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_vertices.Count < 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3[] vertices = _vertices.ToArray();
|
||||
int n = vertices.Length;
|
||||
|
||||
for (var i = 0; i < n; i++)
|
||||
{
|
||||
int j = (i + 1) % n;
|
||||
int k = (i + 2) % n;
|
||||
|
||||
if (Vector3.Cross(vertices[j] - vertices[i], vertices[k] - vertices[j]).LengthSquared() < 1e-6f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of vertices in this polyhedron.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user