Skip to content

Instantly share code, notes, and snippets.

@FaffyWaffles
FaffyWaffles / UnionPolygonController.cs
Last active June 9, 2022 06:08
Polygon Union Algorithm V1
public class UnionPolygonController : SerializedMonoBehaviour
{
public static List<List<Vector2>> UnionPolygon(List<List<Vector2>> uvPolygons)
{
List<List<Vector2>> newPolygons = new List<List<Vector2>>();
#region Fix Winding Order
for (int i = 0; i < uvPolygons.Count; i++)
{
float sum = new float();
@FaffyWaffles
FaffyWaffles / DistinctRandomColors.cs
Last active June 1, 2022 19:32
Unity script to create n number of evenly distributed random colors.
using System.Collections.Generic;
using UnityEngine;
public class DistinctRandomColors : MonoBehaviour
{
public Color[] colors;
void RandomColors(int colorCount, out Color[] colors)
{
colors = new Color[colorCount];
@openroomxyz
openroomxyz / TrinagleArea.cs
Created April 1, 2020 09:41
Unity : How to calculate the Area of Triangle in 3D?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class AreaOfTrinagle : EditorWindow
{
string objectBaseName = "";
int objectId = 1;
@ma11hew28
ma11hew28 / terminal.txt
Last active November 26, 2024 01:22
Unique Unordered Pairing Function
$ ruby unique-unordered-pairing-function.rb
Cantor Pairing Function
-----------------------
<x, y> = (x + y) * (x + y + 1) / 2 + y
0 1 2 3 4 5 6 7 8 9 10 11 12 13
+ ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— + ——— +
0 | 0 | 1 | 3 | 6 | 10 | 15 | 21 | 28 | 36 | 45 | 55 | 66 | 78 | 91 |