Hey, I am trying to find the angles of a triangle with the lengths of the sides. I already tried using math.acos()
to invert the cos in order to find the angle, however the acos always comes back as nan. any fixes or help would be apreciated.
local point = game.Workspace.triangle.point
local point0 = game.Workspace.triangle.point0
local point1 = game.Workspace.triangle.point1
local pointpos =point.Position
local pointpos0 =point0.Position
local pointpos1 =point1.Position
--Keep in mind Z=Y axis because roblox is 3-dimensional
local pointX = pointpos.X
local pointY = pointpos.Z
local point0X = pointpos0.X
local point0Y = pointpos0.Z
local point1X = pointpos1.X
local point1Y = pointpos1.Z
local length = 0
local length0 = 0
local length1= 0
local angle = 0
local angle0 = 0
local angle1 = 0
local function cosinelaw (a,b,c,angle)
print(c)
print(b)
print(a)
print(math.acos(a^2+b^2-c^2/2*a*b))
print(tostring(math.cos(2)))
if angle ==1 then
elseif angle ==2 then
elseif angle == 3 then
end
end
local function calcdistance(x1,y1,x2,y2,side)
--print("length: "..math.sqrt((x1-x2)^2+(y1-y2)^2))
if side == 1 then
length = math.sqrt((x1-x2)^2+(y1-y2)^2)
elseif side == 2 then
length0 = math.sqrt((x1-x2)^2+(y1-y2)^2)
elseif side ==3 then
length1 = math.sqrt((x1-x2)^2+(y1-y2)^2)
end
end
--point and point0
calcdistance(pointX,pointY,point0X,point0Y,1)
--point and point1
calcdistance(pointX,pointY,point1X,point1Y,2)
--point0 and point1
calcdistance(point0X,point0Y,point1X,point1Y,3)
wait(1)
print(length)
print(length0)
print(length1)
wait(4)
cosinelaw(tostring(length),tostring(length0),tostring(length1),1)
type or paste code here