Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local point1 = {3, 1}
- local point2 = {2, 2}
- local point3 = {3, 2}
- function distance(a, b)
- local dist = math.sqrt(math.abs(((a[1]-b[1])^2) + ((a[2]-b[2])^2)))
- return dist
- end
- function angles(first,second, third)
- local dista = distance(first,second)
- local distb = distance(second,third)
- local distc = distance(third, first)
- local anglec = math.acos(((dista^2) + (distb^2) - (distc^2)) / (2*dista*distb))
- local angleb = math.asin(((math.sin(anglec)) / distc) * distb)
- anglec = math.deg(anglec)
- angleb = math.deg(angleb)
- local anglea = 180 - angleb - anglec
- return {anglea, angleb, anglec, dista, distb, distc}
- end
- function findit(point1, point2, point3)
- local tab = angles(point1, point2, point3)
- local all = {{tab[1], tab[4]}, {tab[2], tab[5]}, {tab[3], tab[6]}}
- local vals = {"A", "B", "C"}
- for i = 1, 3 do
- print("Angle ".. vals[i] .. " is " .. all[i][1])
- print("Line ".. string.lower(vals[i]) .. " is " .. all[i][2])
- end
- end
- findit(point1, point2, point3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement