This file contains hidden or 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
private void MergeSort<T>(Span<T> arr, Span<int> indexs, Func<T, T, int> comparer) where T : struct | |
{ | |
var loop = Mathf.CeilToInt(Mathf.Log(arr.Length, 2)); | |
Span<int> indexs1 = stackalloc int[arr.Length]; | |
Span<int> indexs2 = stackalloc int[arr.Length]; | |
for(var i = 0; i < arr.Length; i++) | |
{ | |
indexs1[i] = i; | |
indexs2[i] = i; |
This file contains hidden or 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
using System; | |
using System.Globalization; | |
using UnityEngine; | |
namespace Gists | |
{ | |
/// <summary> | |
/// HSL struct. | |
/// </summary> | |
/// <remarks>ref: https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Math/Color.cs </remarks> |
This file contains hidden or 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
using System; | |
using UnityEngine; | |
namespace Gists | |
{ | |
[Serializable] | |
public class KneeCurve | |
{ | |
[SerializeField] | |
protected float threshold = 0f; |
This file contains hidden or 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
using System.Collections.Generic; | |
using UnityEngine; | |
namespace Gists | |
{ | |
// The algorithm is from the "Fast Poisson Disk Sampling in Arbitrary Dimensions" paper by Robert Bridson. | |
// https://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf | |
public static class FastPoissonDiskSampling | |
{ |
This file contains hidden or 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
using System.Collections; | |
using System.Collections.Generic; | |
using System; | |
using UnityEngine; | |
namespace Gists | |
{ | |
public static class BitonicSort | |
{ | |
public const float InvertLogTwo = 1f / 0.6931471805f; // 1.0 / loge2 |
This file contains hidden or 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
using UnityEngine; | |
using System; | |
using System.Globalization; | |
namespace Gists | |
{ | |
[Serializable] | |
public struct Complex | |
{ | |
public static readonly Complex Zero = new Complex(0f, 0f); |