New Coordinate Calculation of coordinate rotation of three-dimensional coordinate points around any axis

Source: Internet
Author: User
Any axis can be expressed by a starting point and a direction vector. Then, you can first move the axis around any axis to the original point, then rotate it, and then reverse translate the new coordinates. The problem is to calculate the new point after the vector rotates any angle through the origin point. If the unit vector is (RX, Ry, Rz), the rotation matrix is as follows:

Void rotate_point3d (float Theta, float NX, float NY, float NZ, float (& ptin) [3], float (& ptout) [3]) {float Len = sqrtf (nx * Nx + ny * ny + NZ * NZ); // unitized NX/= Len; NY/= Len; NZ/= Len; ptout [0] = ptin [0] * (cosf (theta) + NX * Nx * (1-cosf (theta ))) + // transform by matrix ptin [1] * (nx * Ny * (1-cosf (theta)-NZ * sinf (theta )) + ptin [2] * (nx * NZ * (1-cosf (theta) + ny * sinf (theta ))); ptout [1] = ptin [0] * (nx * Ny * (1-cosf (theta) + NZ * sinf (theta )) + ptin [1] * (Ny * (1-cosf (theta) + cosf (theta )) + ptin [2] * (Ny * NZ * (1-cosf (theta)-NX * sinf (theta )); ptout [2] = ptin [0] * (nx * NZ * (1-cosf (theta)-ny * sinf (theta ))) + ptin [1] * (Ny * NZ * (1-cosf (theta) + NX * sinf (theta )) + ptin [2] * (NZ * (1-cosf (theta) + cosf (theta ));}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.