A function receives 3 positions that make up a triangle and must find the 2 positions that make up the longest side.
My implementation feels hacky, and I suspect there is a better way to do this. How might I improve this?
local sideLengths = {
-- {point on side, other point on side, third point, side length}
{p0, p1, p2, (p0.Position - p1.Position).magnitude},
{p1, p2, p0, (p1.Position - p2.Position).magnitude},
{p2, p0, p1, (p2.Position - p0.Position).magnitude}
}
table.sort(sideLengths, function(a, b) -- Sorts sideLengths in descending order by side length
return a[4] > b[4]
end)
local a = sideLengths[1][1].Position
local b = sideLengths[1][2].Position
local c = sideLengths[1][3].Position