   Rotating a vector
  I know this has been posted before with really great answers ( http://www.gamedev.net/community/forums/topic.asp?topic_id=313276&whichpage=1� ) but I can't get it to work for me. I have no maths skills whatever and absolutely no understanding of trigonometry despite my immense effort. Here's a diagram showing my situation:http://imgur.com/pLjfk.pngI'm just trying to get the observer (the blue box at the bottom) to rotate and move him along that diagonal line. To do this, I believe I have to rotate him around the Y axis and than translate his position. Here are my attempts so far.Bear in mind that I have no idea how these operations work. I've just tried to cobble them together from examples I've read.Attempt 1Vec3* view = new Vec3( 1, 0, 0 ); // looking down that green vertical lineview->x = sin( angle );view->z = cos( angle );view = *view * 5; // lengthening the lineobserverPos->x += view->x;observerPos->y += view->y;observerPos->z += view->z;// Result: goes off way to the right of the observerAttempt 2Vec3* view = new Vec3( 1, 0, 0 ); // looking down that green vertical lineview->x = (float)( cos(angle) * view->x - sin(angle) * view->z );view->z = (float)( sin(angle) * view->x + cos(angle) * view->z );view = *view * 5; // lengthening the lineobserverPos->x += view->x;observerPos->y += view->y;observerPos->z += view->z;// Result: doesn't go enough to the rightAttempt 3Vec3* view = new Vec3( 1, 0, 0 ); // looking down that green vertical lineview->x = ( observerPos->x) * cos(angle) - (observerPos->z) * sin(angle) + observerPos->x;view->z = ( observerPos->z) * cos(angle) + ( observerPos->x) * sin(angle) + observerPos->z;view = *view * 5; // lengthening the lineobserverPos->x += view->x;observerPos->y += view->y;observerPos->z += view->z;// Result: goes off to the right but goes upward the correct amount ( I reckon )I can't stress enough that I have no idea what's going on with these calculations. Can anyone see where I'm going wrong? All input appreciated.   
Quote:I'm just trying to get the observer (the blue box at the bottom) to rotate and move him along that diagonal line.You mean the red box? :SA few questions:1. What programming language are you using?2. If it's C++, are you new to the language by any chance? And do you have a background in a garbage-collected language such as Java or C#? (Not directly relevant to your question, probably, but could be significant from a 'code quality' point of view.)3. Are your angles in radians or degrees?   ;Quote:Original post by jykQuote:I'm just trying to get the observer (the blue box at the bottom) to rotate and move him along that diagonal line.You mean the red box? :SYes, sorry. I mean that this is the end result I want:http://imgur.com/HN5u1.png Quote:A few questions:1. What programming language are you using?2. If it's C++, are you new to the language by any chance? And do you have a background in a garbage-collected language such as Java or C#? (Not directly relevant to your question, probably, but could be significant from a 'code quality' point of view.)3. Are your angles in radians or degrees?C++. I've been coding for years but I'm really simplifying the code here to make it easier for other people to read. I'm using degrees but I could use radians if that's easier (just .314 * 180 or whatever that is - that part isn't a problem).   ;Quote:I'm using degrees but I could use radians if that's easier (just .314 * 180 or whatever that is - that part isn't a problem).Are you sure that's not part of the problem? You said you're using C++, and the C++ math library functions work with radians. You also said that you're using degrees in your own code, but I don't see any conversions in your code anywhere. Also, results such as 'going off way to the right of the observer' would be consistent with using degrees where radians are expected or vice versa.Are you sure you're not missing any conversions?   