|
| 24 Jul 2015 10:42 AM |
I think I have the math right, but under the condition, it should spit out a 45 degree angle. The following script :
local a,b,c = workspace.A,workspace.B,workspace.C
local adjacent = (a.Position-b.Position).magnitude local hypotenuse = (a.Position-c.Position).magnitude local opposite = (c.Position-b.Position).magnitude
local cos = math.cos local rad = math.rad local deg = math.deg
local a = deg(cos(adjacent/hypotenuse))
print(" Adjacent:",adjacent,"\n","Hypotenuse:",hypotenuse,"\n","Opposite:",opposite)
print("Angle:",a)
spits this out in the output
Adjacent: 10 Hypotenuse: 14.142135624 Opposite: 10 Angle: 43.558806810558
If somebody could help me out with this, it'd be much appreciated. |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Jul 2015 10:54 AM |
| using math.acos gives me 45 deg |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Jul 2015 11:14 AM |
Oh, had to inverse it.
local a,b,c = workspace.A,workspace.B,workspace.C
local adjacent = (a.Position-b.Position).magnitude local hypotenuse = (a.Position-c.Position).magnitude local opposite = (c.Position-b.Position).magnitude
local cos = math.cos local rad = math.rad local deg = math.deg
local a = deg(cos(adjacent/hypotenuse))
print(" Adjacent:",adjacent,"\n","Hypotenuse:",hypotenuse,"\n","Opposite:",opposite)
print("Angle:",90-a) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Jul 2015 11:59 AM |
acos gets an angle from adj/hyp.
cos(angle) = adj/hyp acos(cos(angle)) = acos(adj/hyp) angle = acos(adj/hyp) |
|
|
| Report Abuse |
|
|