ios - angle does not produce correct heading vector -
in output vector, x , y values should negative when touchposition top right of player position.
given coordinate system increases upwards , right, starting @ bottom left, can see errors in code might problem?
double oppositelength = (touchposition.y - playerposition.y); double adjacentlength = (touchposition.x - playerposition.x); double hypotenuselength = (sqrt((oppositelength * oppositelength) + (adjacentlength * adjacentlength))); double angle = asin(oppositelength / hypotenuselength); double mass = 0.0000013; cgvector vector = cgvectormake(mass * cos(angle), mass * sin(angle));
here test output… (theta in radians):
o: -119.500000, a: 87.500000, h: 148.109757, theta: -0.938773439
...with vector…:
{7.680115295514375e-07, -1.0488843175016773e-06}
…when touchposition top right of player position.
Comments
Post a Comment