trigonometry in programming
#1

Hello, I've been learning trigonometry lately in my free time and noticed that its often used in programming (as well as in sa-mp). I was wondering, what can trigonometry be used for? and could you give me some examples of code to get my head through the concept.
Reply
#2

Probably the most famous and one of the most simplistic would be getting a position in front of the player https://sampforum.blast.hk/showthread.php?tid=325872 but you could also use it to say calculate the rx, ry of a slope using map andreas. You could calculate animation frames for throwing an object (sine) the uses are endless.
Reply
#3

http://forum.sa-mp.com/showpost.php?...4&postcount=95
Reply
#4

Get direction of Turrent gun to face and shoot player
do stuff with NPC (facing, running, etc..
Reply
#5

Sorry if this is a stupid question.. (Haven't been doing trig for long + only in my spare time (my maths teacher isn't teaching me it yet :c ) )

In the function "Floatsin" it takes an angle.. I thought in order to get the sin of something you need to know the size of the hypotenuse and the size of the opposite side.
Reply
#6

I think that's sin-1. sin(angle) sin-1 (asin or arcsin or something) of the opp/hyp.
Reply
#7

Quote:
Originally Posted by thefatshizms
Посмотреть сообщение
Sorry if this is a stupid question.. (Haven't been doing trig for long + only in my spare time (my maths teacher isn't teaching me it yet :c ) )

In the function "Floatsin" it takes an angle.. I thought in order to get the sin of something you need to know the size of the hypotenuse and the size of the opposite side.
new Float:angle = asin(opp/hyp);
Reply
#8

Okay thanks, I thini I pretty much get it now. The only thing I don't really get is how Floatsin works.
Reply
#9

What do you mean 'how it works'?
Reply
#10

Sine is approximated by using Taylor series
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)