Page 1 of 1

Having problems with cos and sin (figured out)

Posted: Tue Apr 15, 2014 5:19 pm
by henrik9864
I am currently working on a collision detection system an i ran into a problem when i tried to detect if a pos is inside a rotated line

the one fro the y axis works fine but the one for the x axis wont work:

Code: Select all

	--y: v.pos.y - math.sin(v.pos.r) * (v.pos.x-self.pos.x) < self.pos.y
	--x: v.pos.x + math.cos(v.pos.r) * (v.pos.y-self.pos.y) < self.pos.x
and also one more question why is cos returning 1 when the angle is 0 and sin returns 0

woops i just relized that i did a spelling mistake second line in the code is not sin but cos :P so i stil need help

Re: Having problems with cos and sin

Posted: Tue Apr 15, 2014 5:23 pm
by Karai17
use math.cos for the x axis, not math.sin

Re: Having problems with cos and sin (figured out)

Posted: Thu Apr 17, 2014 9:24 pm
by henrik9864
i figured it out :P