Does anybody know the function for “inverse tangent” in C++?
I’m rendering my apartment and have writen a function to build entire walls given it’s starting (x,y) and ending (x,y) coordinates, along with other info such as window and door positions. I need to find Theta of the wall so I can rotate it and translate it to it’s position. So I need to do “inverse tan(deltaY/deltaX)”.
This will NOT always give an accurate answer. The range of the atan function is NOT [0, 2pi], and since different triangles with different values of deltax and deltay can have the same tangent and can produce the same result–you should avoid this using some basic trig. Use the absolute value of deltax and deltay so that you will always get a reference angle on [0, pi/2).
Then, using the signs for the original deltax and deltay, you can add/subtract from 0 or pi to get the actual angle.
Thanks, but I won’t need to do any adjustments. At the very most my theta will fall in the range of [+PI,-PI]. It has worked perfectly for all test cases. Using my program’s createWall function I was able to render my entire appartment in 15 min with no angle screw-ups.