Advertisement

Rotation

Started by July 03, 2003 05:49 PM
0 comments, last by Evlich 21 years, 7 months ago
Hello, I am working on a function that rotates a point around an axis. Here is what I have: Point3D Point3D::rotate(const Point3D &rotation) { long double sins[3] = {sin(rotation.z), sin(rotation.y), sin(rotation.x)}; long double coss[3] = {cos(rotation.z), cos(rotation.y), cos(rotation.x)}; return Point3D(x*coss[0]*coss[1]-y*sins[0]*coss[1]+z*sins[1], x*(sins[0]*coss[2]+coss[0]*sins[1]*sins[2])+y*(coss[0]*coss[2]-sins[0]*sins[1]*sins[2])-z*coss[1]*sins[2], x*(sins[0]*sins[2]-coss[0]*coss[2]*sins[1])+y*(coss[0]*sins[2]+sins[0]*sins[1]*coss[2])+z*coss[1]*coss[2]); } It is very close and I am trying to figure out if it is just computer error or if it is a sign problem or something like that. Can someone check that and make sure that I got it right? Thanks a lot. ~evlich ~Evlich
~Evlich
What is the Point3D &rotation supposed to represent? Is rotation.z the angle of rotation around the z-axis, rotation.x the angle around the x-axis and so on? If so, what order are you performing these rotations in?

As just as a general rule: it''s almost never computer error.

This topic is closed to new replies.

Advertisement