-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
m_EditorVersion: 2021.3.21f1 | ||
m_EditorVersionWithRevision: 2021.3.21f1 (1b156197d683) | ||
m_EditorVersion: 2021.3.22f1 | ||
m_EditorVersionWithRevision: 2021.3.22f1 (b6c551784ba3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using UnityEngine; | ||
using X10D.Drawing; | ||
using X10D.Numerics; | ||
using X10D.Unity.Numerics; | ||
using Quaternion = System.Numerics.Quaternion; | ||
|
||
namespace X10D.Unity; | ||
|
||
public static partial class DebugUtility | ||
{ | ||
/// <summary> | ||
/// Draws a function plot. | ||
/// </summary> | ||
/// <param name="function">The function to plot.</param> | ||
/// <param name="xMin">The minimum X value.</param> | ||
/// <param name="xMax">The maximum X value.</param> | ||
public static void DrawFunction(Func<float, float> function, float xMin, float xMax) | ||
{ | ||
DrawFunction(function, xMin, xMax, 0.1f, Vector3.zero, Color.white, 0.0f, false); | ||
} | ||
|
||
/// <summary> | ||
/// Draws a function plot. | ||
/// </summary> | ||
/// <param name="function">The function to plot.</param> | ||
/// <param name="xMin">The minimum X value.</param> | ||
/// <param name="xMax">The maximum X value.</param> | ||
/// <param name="step">The X increment.</param> | ||
/// <param name="offset">The drawing offset of the circle.</param> | ||
/// <param name="color">The color of the circle.</param> | ||
/// <param name="duration"> | ||
/// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. | ||
/// </param> | ||
/// <param name="depthTest"> | ||
/// <see langword="true" /> if depth test should be applied; otherwise, <see langword="false" />. Passing | ||
/// <see langword="true" /> will have the circle be obscured by objects closer to the camera. | ||
/// </param> | ||
/// <exception cref="ArgumentNullException"><paramref name="function" /> is <see langword="null" />.</exception> | ||
public static void DrawFunction(Func<float, float> function, float xMin, float xMax, float step, in Vector3 offset, | ||
in Color color, float duration, | ||
bool depthTest) | ||
{ | ||
if (function is null) | ||
{ | ||
throw new ArgumentNullException(nameof(function)); | ||
} | ||
|
||
DrawUnjoinedPolyhedron(CreateFunction(function, xMin, xMax, step, Vector3.zero), offset, color, duration, depthTest); | ||
} | ||
|
||
private static Polyhedron CreateFunction(Func<float, float> function, float xMin, float xMax, float step, in Vector3 axis) | ||
{ | ||
var points = new List<System.Numerics.Vector3>(); | ||
for (float x = xMin; x < xMax; x += step) | ||
{ | ||
float y = function(x); | ||
var vector = new System.Numerics.Vector3(x, y, 0); | ||
|
||
if (axis != Vector3.zero) | ||
{ | ||
vector = Quaternion.CreateFromAxisAngle(axis.ToSystemVector(), MathF.PI / 2.0f).Multiply(vector); | ||
} | ||
|
||
points.Add(vector); | ||
} | ||
|
||
return new Polyhedron(points); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# PLACEHOLDER | ||
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! | ||
# Introduction | ||
|
||
X10D (pronounced *extend*), is a .NET package that provides extension methods for numerous types. The purpose of this library is to simplify a codebase by reducing the need for repeated code when performing common operations. Simplify your codebase. Take advantage of .NET. Use extension methods. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# This is the **HOMEPAGE**. | ||
Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files. | ||
## Quick Start Notes: | ||
1. Add images to the *images* folder if the file is referencing an image. | ||
# Introduction | ||
|
||
X10D (pronounced *extend*), is a .NET package that provides extension methods for numerous types. The purpose of this library is to simplify a codebase by reducing the need for repeated code when performing common operations. Simplify your codebase. Take advantage of .NET. Use extension methods. |