Skip to content

Instantly share code, notes, and snippets.

View a3geek's full-sized avatar

a3geek a3geek

View GitHub Profile
@a3geek
a3geek / IndexMergeSort.cs
Created August 31, 2021 04:04
Span index merge sort.
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;
@a3geek
a3geek / HSL.cs
Created October 23, 2020 11:57
HSL struct for Unity3d.
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>
@a3geek
a3geek / KneeCurve.cs
Last active January 5, 2023 04:14
Knee Curve and Soft Knee Curve for Unity.
using System;
using UnityEngine;
namespace Gists
{
[Serializable]
public class KneeCurve
{
[SerializeField]
protected float threshold = 0f;
@a3geek
a3geek / PoissonDiskSampling.cs
Last active February 28, 2024 07:37
Fast Poisson Disk Sampling for Unity.
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
{
@a3geek
a3geek / BitonicSort.cs
Last active July 5, 2018 11:08
Bitonic Sort for Unity C#
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
@a3geek
a3geek / Complex.cs
Last active July 5, 2018 11:08
Complex structure for Unity C#
using UnityEngine;
using System;
using System.Globalization;
namespace Gists
{
[Serializable]
public struct Complex
{
public static readonly Complex Zero = new Complex(0f, 0f);