Basic Trigonometry Isn't Working Correctly In Python
For a bit of background, this is the game I'm trying to draw in an isometric style. I'm just trying to get the correct calculations instead of doing it in a hacky way, but one part
Solution 1:
As stated in the comments you need to convert to radians which can be done with the
math.radians()
function. So in practice you would end with something like
height = 2 * sin(math.radians(iso_angle)) * grid_length
width = 2 * cos(math.radians(iso_angle)) * grid_length
Solution 2:
The cursor module (turtle) takes angles in degrees.
The sin() and cos() math functions take angles in radians. You must convert them. Fortunetly, Python includes convenient functions to do that in the math module:
height = 2 * sin(radians(iso_angle)) * grid_length
Hope this helps.
Post a Comment for "Basic Trigonometry Isn't Working Correctly In Python"