Hi
me and math don't really go well together, but there's something i noticed in your code:
Quote:
Code:
height = 500/sides * tan_angle;
|
in general, when doing a multiple operators calculation, it's better to add parenthesis to define precedence. even if the natural precedence is the requested one.
there are 2 reasons for that:
1) to increase readability of the code.
if someone else reads the code, they know that you indeed meant what you wrote and not did a mistake(and when debugging someone else's code something like that can cause a LOT of trouble based on my experience)
2) to make sure you don't accidently ignore the precedence of a certain operator. for example, i once ignored the precedence of the operator & as a bitwise AND. something which caused my program to return erroneous results in several locations.
i don't know if it has anything to do with the problem you have, but IMHO i believe that's a more clear and safe way to write code.