mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:25:41 +00:00
Add Polygon/Polyhedron extension methods for Unity vector types
This commit is contained in:
parent
43a155ad90
commit
eaa88ce11a
34
X10D.Unity/src/Drawing/PolygonExtensions.cs
Normal file
34
X10D.Unity/src/Drawing/PolygonExtensions.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
using X10D.Drawing;
|
||||
using X10D.Unity.Numerics;
|
||||
|
||||
namespace X10D.Unity.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Drawing-related extension methods for <see cref="Polygon" />.
|
||||
/// </summary>
|
||||
public static class PolygonExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a vertex to this polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon whose points to update.</param>
|
||||
/// <param name="point">The point to add.</param>
|
||||
public static void AddVertex(this Polygon polygon, Vector2Int point)
|
||||
{
|
||||
polygon.AddVertex(point.ToSystemPoint());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of vertices to this polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon whose vertices to update.</param>
|
||||
/// <param name="vertices">The vertices to add.</param>
|
||||
public static void AddVertices(this Polygon polygon, IEnumerable<Vector2Int> vertices)
|
||||
{
|
||||
foreach (Vector2Int vertex in vertices)
|
||||
{
|
||||
polygon.AddVertex(vertex);
|
||||
}
|
||||
}
|
||||
}
|
57
X10D.Unity/src/Drawing/PolygonFExtensions.cs
Normal file
57
X10D.Unity/src/Drawing/PolygonFExtensions.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using X10D.Drawing;
|
||||
using X10D.Unity.Numerics;
|
||||
|
||||
namespace X10D.Unity.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Drawing-related extension methods for <see cref="PolygonF" />.
|
||||
/// </summary>
|
||||
public static class PolygonFExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a point to this polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon whose vertices to update.</param>
|
||||
/// <param name="vertex">The vertex to add.</param>
|
||||
public static void AddVertex(this PolygonF polygon, Vector2Int vertex)
|
||||
{
|
||||
polygon.AddVertex(vertex.ToSystemPoint());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a point to this polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon whose vertices to update.</param>
|
||||
/// <param name="vertex">The vertex to add.</param>
|
||||
public static void AddVertex(this PolygonF polygon, Vector2 vertex)
|
||||
{
|
||||
polygon.AddVertex(vertex.ToSystemPointF());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of vertices to this polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon whose vertices to update.</param>
|
||||
/// <param name="vertices">The vertices to add.</param>
|
||||
public static void AddVertices(this PolygonF polygon, IEnumerable<Vector2Int> vertices)
|
||||
{
|
||||
foreach (Vector2Int vertex in vertices)
|
||||
{
|
||||
polygon.AddVertex(vertex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of vertices to this polygon.
|
||||
/// </summary>
|
||||
/// <param name="polygon">The polygon whose vertices to update.</param>
|
||||
/// <param name="vertices">The vertices to add.</param>
|
||||
public static void AddVertices(this PolygonF polygon, IEnumerable<Vector2> vertices)
|
||||
{
|
||||
foreach (Vector2 vertex in vertices)
|
||||
{
|
||||
polygon.AddVertex(vertex);
|
||||
}
|
||||
}
|
||||
}
|
57
X10D.Unity/src/Drawing/PolyhedronExtensions.cs
Normal file
57
X10D.Unity/src/Drawing/PolyhedronExtensions.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using X10D.Drawing;
|
||||
using X10D.Unity.Numerics;
|
||||
|
||||
namespace X10D.Unity.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Drawing-related extension methods for <see cref="Polyhedron" />.
|
||||
/// </summary>
|
||||
public static class PolyhedronExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a vertex to this polyhedron.
|
||||
/// </summary>
|
||||
/// <param name="polyhedron">The polyhedron whose vertices to update.</param>
|
||||
/// <param name="vertex">The vertex to add.</param>
|
||||
public static void AddVertex(this Polyhedron polyhedron, Vector3Int vertex)
|
||||
{
|
||||
polyhedron.AddVertex(vertex.ToSystemVector());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a vertex to this polyhedron.
|
||||
/// </summary>
|
||||
/// <param name="polyhedron">The polyhedron whose vertices to update.</param>
|
||||
/// <param name="vertex">The vertex to add.</param>
|
||||
public static void AddVertex(this Polyhedron polyhedron, Vector3 vertex)
|
||||
{
|
||||
polyhedron.AddVertex(vertex.ToSystemVector());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of vertices to this polyhedron.
|
||||
/// </summary>
|
||||
/// <param name="polyhedron">The polyhedron whose vertices to update.</param>
|
||||
/// <param name="vertices">The vertices to add.</param>
|
||||
public static void AddVertices(this Polyhedron polyhedron, IEnumerable<Vector3Int> vertices)
|
||||
{
|
||||
foreach (Vector3Int vertex in vertices)
|
||||
{
|
||||
polyhedron.AddVertex(vertex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of vertices to this polyhedron.
|
||||
/// </summary>
|
||||
/// <param name="polyhedron">The polyhedron whose vertices to update.</param>
|
||||
/// <param name="vertices">The vertices to add.</param>
|
||||
public static void AddVertices(this Polyhedron polyhedron, IEnumerable<Vector3> vertices)
|
||||
{
|
||||
foreach (Vector3 vertex in vertices)
|
||||
{
|
||||
polyhedron.AddVertex(vertex);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user