Skip to content

Instantly share code, notes, and snippets.

@Quenty
Created November 10, 2019 05:40
Show Gist options
  • Save Quenty/b19d8365db90a297c8183487437e23c6 to your computer and use it in GitHub Desktop.
Save Quenty/b19d8365db90a297c8183487437e23c6 to your computer and use it in GitHub Desktop.
local function cross(vector0, vector1)
local ux, uy = vector0[1], vector0[2]
local vx, vy = vector1[1], vector1[2]
return ux*vy - uy*vx
end
local function area(points)
local area = cross(points[#points], points[1])
for i=1, #points-1 do
area = area + cross(points[i], points[i+1])
end
return 0.5*area
end
local function fakePermutate(points)
local largest = -math.huge
-- TODO: Permutate properly
for i=1, 24 do
local parea = area(points)
if parea > largest then
largest = parea
-- TODO: Store
end
end
return largest
end
local points = {
{ 1, 1, },
{ 3, 3, },
{ 5, 5, },
{ 8, 8, },
}
local startTime = tick()
for i=1, 220000 do
fakePermutate(points)
end
print("done", tick() - startTime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment