You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
t: t parameter, this is for convenience (as assert does).
Example code
A function which computes a triangle area from three points.
functiontriangle_area(a, b, c)
-- AssertMetatable triggers an error if a, b or c is not a vec2AssertMetatable(a, "vec2")
AssertMetatable(b, "vec2")
AssertMetatable(c, "vec2")
localside1=a:Distance(b)
localside2=b:Distance(c)
localside3=c:Distance(a)
-- Sum of any two sides must be smaller than third sideif (side1+side2<=side3orside1+side3<=side2orside2+side3<=side1) thenerror("not a valid triangle")
endlocals= (side1+side2+side3) /2.0;
returnmath.sqrt(s* (s-side1) * (s-side2) * (s-side3))
end-- Prints 50.0print(Vec2(0.0, 0.0), Vec2(5.0, 10.0), Vec2(10.0, 0.0))