Jump to content

math.sin + math.cos


Atti

Recommended Posts

Posted

These math functions are used to get a position in front of a player, by getting his rotation, i.e. for spawning ramps.

Now i need them in my script, but i don't like using things that i don't understand, so can you simply explcate me how these work? Or at least what values should i pass to the functions.

Thx a lot if you can do it, i'm really a n00b in maths. :P

Posted

I've got no problems copying that code. I just would like to understand why an x coord reduced by the sin of the radius of the Z rotation is placed in fornt of the player. :fadein:

Posted

It's basic trig - how to rotate a point round any other. In the ramp examples the origin is set to the vehicle/player and the remote object becomes the "point" to be rotated.

Posted
Useless page. I know functions, i dunno WHAT are sin and cos. :mrgreen:

you might wanna ask your maths teacher :P or visit this site

http://en.wikipedia.org/wiki/Trigonometry

and these sites are awesome to help you visualize how the trigonometric circle works

http://www.senocular.com/flash/source.php?id=0.114

http://www.edumedia-sciences.com/a348_l ... ircle.html

keep in mind that Lua uses radians for math.cos, math.sin etc and MTA uses degrees, so for example if you get a player's rotation you need to convert it to radians when using these functions like this: math.cos ( math.rad ( getPlayerRotation ( getLocalPlayer() ) )

:d::i::s::g::r::a::c::e:

norby89.png

Posted

Useless ? Wow. I shows EXACTLY how they work with the examples. My god...

And inverses

math.acos , math.asin

Return the inverse cosine and sine of the given value.

> = math.acos(1)

0

> = math.acos(0)

1.5707963267949

> = math.asin(0)

0

> = math.asin(1)

1.5707963267949

"The humble beet is the answer to all riddles." - Rolf

Posted
Useless ? Wow. I shows EXACTLY how they work with the examples. My god...

well someone who doesn't know trig can find it useless

:d::i::s::g::r::a::c::e:

norby89.png

Posted

You can learn how it works. I don't know trig but I can understand it and I learned from using LUA. Just make some simple math functions that output the answer to chat to learn them.. It is fairly simple.

"The humble beet is the answer to all riddles." - Rolf

Posted
You can learn how it works. I don't know trig but I can understand it and I learned from using LUA. Just make some simple math functions that output the answer to chat to learn them.. It is fairly simple.

dunno about you but if I didn't know about the basics of trig I'd have no idea what sine and cosine are, I'd say it outputs random numbers :P and probably would ask for help like Atti did

Lua doesn't teach you math

:d::i::s::g::r::a::c::e:

norby89.png

Posted

I get sin and cos extensively at school and I work with them (at school) regularly, but I cant really visualize what happens when you do it on the x,y,z coords.

But I guess i'd just have to experiment and see

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...