I'm making a simple Android tablet game and am stuck at a seemingly simple math problem.
I have a touchpad that generates the angle your finger is touching from the center. This is based on 0 degrees is at 3-oclock and is working fine.
With my finger on 45 degrees, I want to fire an object off from a given point at that angle, knowing the item can travel 150 pixels in range. My math son tells me the formula but I believe it figures coordinates based on 0,0 being the bottom left where as 0,0 is top left.
His math is this:
xDirection = range(hypotenuse) * Math.cos(angle);
yDirection = range(hypotenuse) * Math.sin(angle);
This math however returns some very abnormal results. If I'm at a perfect 0 degrees the math is right, it tells me the xDirection is 100 which is my range and yDirection is 0. If I am at 90 degrees it gives me an xDirection of -44 and a yDirection of 89.
My xDirection and yDirection represent how many pixels on the x and y axis my bullet will need to travel to fulfill its range at the angle my touch pad is at.
This is probably simple math for others but I'm lost! Any help would be SUPERB!