#### Archived

This topic is now archived and is closed to further replies.

# Rotation

This topic is 5585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632930
• Total Posts
3009290
• ### Who's Online (See full list)

There are no registered users currently online

×