you could have just found the taylor numbers for sine on the internet, also to extend it to [0,Pi] you could have just added an if(pi>ang>pi/2), then decrease the angle by pi then multiply the result by -1, you could have just as well extended it to -inf;+inf easily