bug fix, enhancements

calculate position after width is set, improved trigonometric
algorithms.