Tag Info

Hot answers tagged

1

No conditions, you don't need normalised vectors, a single trig function: Vector2 pc = p - c; float crossp = pc.x * ray.direction.y - pc.y * ray.direction.x; float dotp = pc.x * ray.direction.x + pc.y * ray.direction.y; return Math.atan2(crossp, dotp); Here is the explanation. A fast summary: Cross product between two vectors is the same as sin(theta) * ...


1

The white vector is the correct vector with the code you have. If you're only ever adding integers to your position, the movement is going to be at increments of 45 degrees. That's restricted to orthogonal and diagonal movement only. If you want free movement you should be normalizing the movement vector. Check to see if the libraries you're using have a ...



Only top voted, non community-wiki answers of a minimum length are eligible