I think this is a degrees/radians issue, but I'm not sure how you're expecting the numbers you've got. Consider your inputs:
speed = 100
heading = 45
a1 = 90
o1 = a1 - heading
m1 = speed * math.sin(o1)
Then I would expect o1 = 90 - 45
, or o1 = 45
, and then I would expect m1 = 100 * sin(45)
. Here's where it's not clear. Typically I would expect a trig function like sine, cosine, tangent, etc. to take the input in radians unless the document explicitly states otherwise.
Let's assume it is in degrees, though. In that case, the sine of 45 degrees is 0.7071
, and so I would expect (in degrees) m1 = 100 * 0.7071
or m1 = 70.71
. You stated you're expecting it to be 100
, so I'm not sure where that's coming from.
However, what if the math.sin
is treating your input as being in radians? Well, 45 radians is a TON - multiply by 360 and divide by $2\pi$ to get 45rad = 2578.4deg
. What is the sine of 2,578.4 degrees? 0.852. So, if you're passing in 45 radians, then you wind up with m1 = 100 * 0.852
or m1 = 85.2
. If you're casting to int
or something then you wind up with m1 = 85
, which is what you got.
For m2
, you're taking 210-45
and then treating that as radians, but 165rad = 9454deg
. Then, sine of 9,454 degrees is 0.998, and you wind up with m2 = 99.8
, which rounds to 100
.
Try converting to radians first and double-check your expected values and hopefully that gets everything straight for you :)
m1 = 70.71, m2 = 25.88, m3 = -96.59
$\endgroup$