Define Acos trig function for consine law

debug i tried. i found out how to do it though

`-- References to the points in the workspace
local point = game.Workspace.triangle.point
local point0 = game.Workspace.triangle.point0
local point1 = game.Workspace.triangle.point1

– Positions of the points
local pointpos = point.Position
local pointpos0 = point0.Position
local pointpos1 = point1.Position

– Coordinates of the points (note Z is Y axis in Roblox)
local pointX = pointpos.X
local pointY = pointpos.Z

local point0X = pointpos0.X
local point0Y = pointpos0.Z

local point1X = pointpos1.X
local point1Y = pointpos1.Z

– Distances between points
local length = 0
local length0 = 0
local length1 = 0

– Function to calculate distance between two points
local function calcdistance(x1, y1, x2, y2, side)
local distance = math.sqrt((x1 - x2)^2 + (y1 - y2)^2)
if side == 1 then
length = distance
elseif side == 2 then
length0 = distance
elseif side == 3 then
length1 = distance
end
end

– Calculate distances
calcdistance(pointX, pointY, point0X, point0Y, 1)
calcdistance(pointX, pointY, point1X, point1Y, 2)
calcdistance(point0X, point0Y, point1X, point1Y, 3)

– Function to calculate angle using the law of cosines
local function cosinelaw(a, b, c)
local cos_theta = (a^2 + b^2 - c^2) / (2 * a * b)
if cos_theta >= -1 and cos_theta <= 1 then
return math.acos(cos_theta)
else
return nil – Return nil if cos_theta is out of valid range
end
end

– Calculate angles in radians
local angle = cosinelaw(length, length0, length1)
local angle0 = cosinelaw(length0, length1, length)
local angle1 = cosinelaw(length1, length, length0)

– Print distances
print("Length: " … length)
print("Length0: " … length0)
print("Length1: " … length1)

– Print angles in radians
print("Angle (radians): " … (angle or “Invalid”))
print("Angle0 (radians): " … (angle0 or “Invalid”))
print("Angle1 (radians): " … (angle1 or “Invalid”))

– Optional: Print angles in degrees
if angle then print("Angle (degrees): " … math.deg(angle)) end
if angle0 then print("Angle0 (degrees): " … math.deg(angle0)) end
if angle1 then print("Angle1 (degrees): " … math.deg(angle1)) end
`