Hi, I want to make a calculator in GMod. However, math.sin() or other functions which work in Lua do not work in GMod. Is there anyway to import the lua library to GMod?
Or, is there a way to make scientific calculation such as sin, or exponential calculation? (I know Taylor Series is a solution... But is there a better way besides mathematical approximation method?)
Thanks!
math.sin does exist. [url=http://wiki.garrysmod.com/?search=Math][B]Math[/B] [img]http://wiki.garrysmod.com/favicon.ico[/img][/url]
What?
[lua]local sinVal = math.sin( 90 )[/lua]
sinVal is now 1
[del]But bear in mind math.sin returns the sin in radians, not degrees.[/del]
Takes the argument in radians, apologies.
But it's a simple conversion back, so no matter.
[QUOTE=Entoros;19578957]But bear in mind math.sin returns the sin in radians, not degrees.[/QUOTE]
Last time I checked radians didn't go from -1 to 1. Radians are measured in fractions of pi.
[list]
[*]0 degrees = 0 radians
[*]90 degrees = 1.57 radians
[*]180 degrees = 3.14 radians
[*]270 degrees = 4.71 radians
[*]360 degrees = 6.28 radians
[/list]
[quote=The Wiki]"Returns the sine of a number (in radians)."[/quote]
I mean, please edit the Wiki if I'm wrong.
I'm pretty sure it returns negative because you're passing a degree argument to a function that takes radians.
...Or maybe I was just being a little unclear. Sorry about that.
Get it. Thanks!
It is case sensitive, and it should be math.sin(Value).
[QUOTE=FAU78;19594897]It is case sensitive[/QUOTE]
Welcome to coding.
[QUOTE=Bletotum;19595217]Welcome to coding.[/QUOTE]
Er... Really new to GMod, actually the whole half-life series game. Almost know nothing but killing myself by dropping a carbin...
-
Sorry, you need to Log In to post a reply to this thread.