Having problems with cos and sin (figured out)

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
henrik9864
Prole
Posts: 11
Joined: Mon Sep 02, 2013 3:58 pm

Having problems with cos and sin (figured out)

Post 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
Last edited by henrik9864 on Thu Apr 17, 2014 9:23 pm, edited 2 times in total.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Having problems with cos and sin

Post by Karai17 »

use math.cos for the x axis, not math.sin
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
henrik9864
Prole
Posts: 11
Joined: Mon Sep 02, 2013 3:58 pm

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

Post by henrik9864 »

i figured it out :P
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests