This file contains 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
function monotonicSteffen(y0, y1, y2, y3, x0, x1, x2, x3, x) | |
local x1x0, x2x1, x3x2 = x1-x0, x2-x1, x3-x2 | |
local delta0, delta1, delta2 = (y1-y0) / (x1x0 + 1e-30), (y2-y1) / (x2x1 + 1e-30), (y3-y2) / (x3x2 + 1e-30) | |
local m1 = (sign(delta0)+sign(delta1)) * min(abs(delta0),abs(delta1), 0.5*abs((x2x1*delta0 + x1x0*delta1) / (x2-x0 + 1e-30))) | |
local m2 = (sign(delta1)+sign(delta2)) * min(abs(delta1),abs(delta2), 0.5*abs((x3x2*delta1 + x2x1*delta2) / (x3-x1 + 1e-30))) | |
local xx1 = x - x1 | |
local xrel = xx1 / max(x2x1, 1e-30) | |
return y1 + xx1*(m1 + xrel*(delta1 - m1 + (xrel - 1)*(m1 + m2 - 2*delta1))) | |
end |
This file contains 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
# 12345 | |
greenletters = "....." | |
yelloletters=[ ".....", | |
".....", | |
".....", | |
"....." ] | |
greyletters = "" | |
f = {"a":7.8, "b":2, "c":4, "d":3.8, "e":11, "f":1.4, "g":3, "h":2.3, "i":8.6, | |
"j":0.21, "k":0.97, "l":5.3, "m":2.7, "n":7.2, "o":6.1, "p":2.8, "q":0.19, "r":7.3, |
This file contains 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
function overlapsOBB_OBB(c1, x1, y1, z1, c2, x2, y2, z2) | |
local cc = c1 - c2 | |
local d11, d12, d13 = abs(x1:dot(x2)), abs(x1:dot(y2)), abs(x1:dot(z2)) | |
local d21, d22, d23 = abs(y1:dot(x2)), abs(y1:dot(y2)), abs(y1:dot(z2)) | |
local d31, d32, d33 = abs(z1:dot(x2)), abs(z1:dot(y2)), abs(z1:dot(z2)) | |
return abs(cc:dot(x1))-d11-d12-d13<=x1:squaredLength() and abs(cc:dot(y1))-d21-d22-d23<=y1:squaredLength() | |
and abs(cc:dot(z1))-d31-d32-d33<=z1:squaredLength() and abs(cc:dot(x2))-d11-d21-d31<=x2:squaredLength() | |
and abs(cc:dot(y2))-d12-d22-d32<=y2:squaredLength() and abs(cc:dot(z2))-d13-d23-d33<=z2:squaredLength() | |
end |
This file contains 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
--== Spring based temporal ==-- | |
local temporalSpring = {} | |
temporalSpring.__index = temporalSpring | |
function newTemporalSpring(spring, damp, startingValue) | |
local data = {spring = spring or 10, damp = damp or 2, state = startingValue or 0, vel = 0} | |
setmetatable(data, temporalSpring) | |
return data | |
end |
This file contains 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
function randomPointInSphere(radius) | |
radius = radius or 1 | |
local sx, sy, sz = 0, 0, 0; | |
for i = 1, 4 do | |
local x, y, z = math.random(), math.random(), math.random() | |
sx, sy, sz = sx + x, sy + y, sz + z | |
local xc, yc, zc = x - 0.5, y - 0.5, z - 0.5 | |
if xc * xc + yc * yc + zc * zc <= 0.25 then | |
local r2 = radius * 2 | |
return xc * r2, yc * r2, zc * r2 |
This file contains 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
function overlapsOBB_OBB(c1, x1, y1, z1, c2, x2, y2, z2) | |
local cc = c1 - c2 | |
local d11, d12, d13 = abs(x1:dot(x2)), abs(x1:dot(y2)), abs(x1:dot(z2)) | |
local d21, d22, d23 = abs(y1:dot(x2)), abs(y1:dot(y2)), abs(y1:dot(z2)) | |
local d31, d32, d33 = abs(z1:dot(x2)), abs(z1:dot(y2)), abs(z1:dot(z2)) | |
return abs(cc:dot(x1))-d11-d12-d13<=x1:squaredLength() and abs(cc:dot(y1))-d21-d22-d23<=y1:squaredLength() and abs(cc:dot(z1))-d31-d32-d33<=z1:squaredLength() | |
and abs(cc:dot(x2))-d11-d21-d31<=x2:squaredLength() and abs(cc:dot(y2))-d12-d22-d32<=y2:squaredLength() and abs(cc:dot(z2))-d13-d23-d33<=z2:squaredLength() | |
end |
This file contains 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
#include <algorithm> | |
#include <future> | |
#include <thread> | |
template<typename randomIt, typename FN> | |
void parallel_for(const randomIt start, const randomIt end, const int step, const FN &mapFun, const int threadCount = -1, const int granularity = 1, const int threadStart = 0) noexcept { | |
int threadSize = threadCount; | |
if (threadSize < 0) { | |
const unsigned threadHint = std::thread::hardware_concurrency(); | |
threadSize = threadHint == 0 ? 2 : threadHint; |
This file contains 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
# ISC License | |
# Copyright (c) 2017, Lefteris Stamatogiannakis | |
# Permission to use, copy, modify, and/or distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
This file contains 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
# ISC License | |
# Copyright (c) 2017, Lefteris Stamatogiannakis | |
# Permission to use, copy, modify, and/or distribute this software for any | |
# purpose with or without fee is hereby granted, provided that the above | |
# copyright notice and this permission notice appear in all copies. | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |