First off i'd like to say that this account was created because my real account "SillyNoob" has completely locked up. Make new thread "Sorry, you can't do that", new PM "Sorry you can't do that", post on my own thread and there's no reply button. There's no PM in my inbox and no email in my registered email account so I don't know what's going on here but whatever it is i'm not laughing
Now onto the actual post. Basically I'm a complete idiot for not being able to solve this simple problem. I have a line and I want that line to rotate by either +X or -X degrees when the user presses a button. If they press Z it rotates minus whatever degrees and if they press X it rotates plus whatever degrees. Simple, right?
Well Mr.Stupid here can't implement it because he's attrocious at math and essentially doesn't know what he's doing. There's no cause for alarm in the code overload department because all my problems are in this simple class member function. The function only deals with the co-ordinates of point 2 since point 1 will always be in the same place.
// sets X/Y values to correspond to a rotation of TurrVector by _ degrees
void TurrVector::Rotate(int x, int y, double angle)
{
// convert angle given into radians for sine & cosine functions
double angInRad = (angle*PI)/180;
double xInRad = (x*cos(angInRad)) - (y*sin(angInRad));
double yInRad = (x*sin(angInRad)) + (y*cos(angInRad));
// convert radians back into degrees before assigning new X/Y
p2[0] += (xInRad*180)/PI;
p2[1] += (yInRad*180)/PI;
}
I'd like to say that I don't take any credit for the code written in this function because it's essentially a copy/paste job from back when I read this page, didn't understand what they were trying to teach me and took the end product.
[http://freespace.virgin.net/hugo.elias/routines/rotate.htm]
As always I thank any of you who take time out of your lives to read and post here to help out idiots like me :)