Skip to content

Instantly share code, notes, and snippets.

@meta-hub
meta-hub / curve.lua
Last active August 4, 2022 04:29
A curve metatable for lua.
local Curve = {}
function Curve:get(time)
for i=2,#self.keys,1 do
local nextKey = self.keys[i]
local preKey = self.keys[i-1]
if (nextKey.time == time) then
return nextKey.value
end
--[[
polyzone.lua
Lua implementation of winding number algorithm to determine whether a point is inside a polygon
Credits:
https://gist.github.com/vlasky/d0d1d97af30af3191fc214beaf379acc - Public wn_PnPoly js conversion
http://geomalgorithms.com/a03-_inclusion.html - Original wn_PnPoly function
--]]
@meta-hub
meta-hub / point_in_polygon_using_winding_number.js
Created February 25, 2022 00:54 — forked from vlasky/point_in_polygon_using_winding_number.js
JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//Based on C++ implementation of wn_PnPoly() published on http://geomalgorithms.com/a03-_inclusion.html
function pointInPolygon(point, vs) {
const x = point[0], y = point[1];
let wn = 0;
for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
let xi = vs[i][0], yi = vs[i][1];
let xj = vs[j][0], yj = vs[j][1];
@meta-hub
meta-hub / file.lua
Created October 20, 2021 07:51
File/IO helper with Lua
local fileMt = {}
fileMt.__index = fileMt
function fileMt:exists()
local f = io.open(self.path,"r")
if f then
f:close()
end
@meta-hub
meta-hub / merger.py
Last active October 20, 2021 07:49
Merge files with Python
# merger.py
# A simple image merger utility script.
# Written by Brayden Haynes - [email protected]
# usage:
# py merger.py mergefolder1 mergefolder2 mergefolder3 ...
import sys
import os, os.path
from PIL import Image
@meta-hub
meta-hub / perlin.lua
Last active April 19, 2022 20:10 — forked from kymckay/perlin.lua
Perlin Noise in Lua
local defaultSeed = 1337
local dot_product = {
[0x0]=function(x,y,z) return x + y end,
[0x1]=function(x,y,z) return -x + y end,
[0x2]=function(x,y,z) return x - y end,
[0x3]=function(x,y,z) return -x - y end,
[0x4]=function(x,y,z) return x + z end,
[0x5]=function(x,y,z) return -x + z end,
[0x6]=function(x,y,z) return x - z end,