1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 14:28:47 +00:00

refactor: remove Polyhedron.IsConvex

This commit is contained in:
Oliver Booth 2023-04-03 14:16:31 +01:00
parent 9417ee6be1
commit 15d0f93f8b
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -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>