|
| 16 Jul 2015 08:09 PM |
Hmmm, I can't make this script print the degree of angle C according to this image:
http://prntscr.com/7tlrkr
local function GetCos(a, b, c, Angle) if Angle == "A" then print(math.deg((b^2 + c^2 - a^2)/(2 * (b * c)))) elseif Angle == "B" then print(math.deg((c^2 + a^2 - b^2)/(2 * (c * a)))) elseif Angle == "C" then print(math.deg((a^2 + b^2 - c^2)/(2 * (a * b)))) end end
GetCos(44, 29, 50, "C") |
|
|
| Report Abuse |
|
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 16 Jul 2015 08:17 PM |
How?
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2015 08:18 PM |
local function GetCos(a, b, c, Angle) if Angle == "A" then print(math.deg(math.acos((b^2 + c^2 - a^2)/(2 * (b * c))))) elseif Angle == "B" then print(math.deg(math.acos((c^2 + a^2 - b^2)/(2 * (c * a))))) elseif Angle == "C" then print(math.deg(math.acos((a^2 + b^2 - c^2)/(2 * (a * b))))) end end
GetCos(44, 29, 50, "A") |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
| |
|
|
| 16 Jul 2015 08:40 PM |
| math cos gives me a weird radian |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 16 Jul 2015 08:46 PM |
| math.deg it and round it to whatever precision you wanted |
|
|
| Report Abuse |
|
|