Skip to content

Instantly share code, notes, and snippets.

View deerchao's full-sized avatar

Chao Lu deerchao

View GitHub Profile
@JohannesMP
JohannesMP / ClosestPointOnEllipse.cs
Last active June 17, 2024 00:43
[C#, Unity3D] Quickly find the closest point on an ellipse centered on the origin.
using UnityEngine;
using Math = System.Math;
public static class NearestPointTo
{
/// <summary>
/// Find the closest point on an ellipse centered on the origin.
/// </summary>
/// Credit:
/// 2015-09 Original Paper by Luc. Maisonobe https://www.spaceroots.org/documents/distance/distance-to-ellipse.pdf
@dadhi
dadhi / Lens.cs
Last active February 23, 2024 09:41
Functional optics, e.g. Lens, in C# - to simplify access and modification for deep part of immutable value
/*
Inspired by: https://medium.com/@gcanti/introduction-to-optics-lenses-and-prisms-3230e73bfcfe
*/
using System;
using static System.Console;
public static class Program
{
public static void Main()
@linchpinstudios
linchpinstudios / fabric.arrow.js
Last active December 25, 2023 18:27
Fabric JS Arrow
fabric.Arrow = fabric.util.createClass(fabric.Line, {
type: 'Arrow',
initialize: function(element, options) {
options || (options = {});
this.callSuper('initialize', element, options);
},
toObject: function() {