Skip to content

Instantly share code, notes, and snippets.

View EgoMoose's full-sized avatar

EgoMoose

  • Canada
View GitHub Profile
@EgoMoose
EgoMoose / ViewportModel.lua
Last active March 9, 2024 03:32
Lua class to calculate camera distance/cframe for fitting models into viewport frames
--[[
MIT License
Copyright (c) 2021 EgoMoose
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@EgoMoose
EgoMoose / RthroScaleFix.lua
Last active December 12, 2023 21:52
Adjusts Roblox Rthro avatars so that their height scales match a 5 stud high R15 rig
--[[
MIT License
Copyright (c) 2021 EgoMoose
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@EgoMoose
EgoMoose / GetSurfaceCFrame.lua
Created January 29, 2021 00:00
Lua function for geting a surface cframe and size that is aligned to a surface gui
local UNIT_X = Vector3.new(1, 0, 0)
local UNIT_Y = Vector3.new(0, 1, 0)
local SPIN_Y = CFrame.fromEulerAnglesXYZ(0, -math.pi/2, 0)
local function getRotationBetween(u, v, axis)
local dot, uxv = u:Dot(v), u:Cross(v)
if dot < -0.99999 then return CFrame.fromAxisAngle(axis, math.pi) end
return CFrame.new(0, 0, 0, uxv.x, uxv.y, uxv.z, 1 + dot)
end
@EgoMoose
EgoMoose / quadraticBezierLength.lua
Created December 9, 2017 21:51
Calculates the arc length of a quadratic Bezier curve from 0 to t
local abs = math.abs;
local log = math.log;
local sqrt = math.sqrt;
-- calculates length from 0 to t (where t is a percentage eg 1 = 100%).
local function quadraticBezierLength(t, p0, p1, p2)
local a = p0 - 2*p1 + p2;
local b = 2*(p1 - p0);
local A = 4*(a:Dot(a));
local B = 4*(a:Dot(b));
@EgoMoose
EgoMoose / _README.md
Created August 16, 2016 22:32 — forked from mauriciopoppe/_README.md
requirebin sketch