Labeling rotation with measured objects

Source: Internet
Author: User

Assume that we have marked the red line segments in the following blocks, then the two anchor points marked are the two endpoints of the red line segments respectively.

When we rotate this block, we naturally hope that this label will also rotate along with the object and adjust it to the following reasonable position,

The question now is how to obtain the transformation matrix for this annotation.

At first, I thought that we only needed to obtain the transformation matrix based on the initial red position and the ending position, and then apply it to the annotation. However, after the result, I found myself thinking simple. In the second figure above, you can continue to rotate the block around the Red Line Segment, for example, to get the following shape:

We found that the second image corresponds to the vector of the red line segment in the third image, so the calculated transformation matrix must be the same as that in the second image, the result must be the following:

The correct result should be as follows:

The root cause of this problem is:A straight line cannot determine the plane.So we can't decide the plane at. We can do it. The key issue is how to select the third point. The third point must be stable relative to the red line segment, so after the block is rotated, we can still find it back. So I thought of finding the center point of the block, and then building a plane. According to the position before and after the plane, the problem was solved by obtaining the matrix of changes.

 

Original matrix:

Vector3d vecx = (P2-P1). Normal ();
Vector3d refvec = (centerpoint-P1). mormal ();
Vector3d vecz = vecx. crossproduct (refvec );
Vector3d vecy = vecx. crossproduct (vecz );
Matrix3d m0 = new matrix3d ();
M0.setcoordinatesystem (P1, vecx, vecy, vecz); // orignal Transform

New matrix:

Vector3d vecx' = (P2 '-p1'). Normal ();
Vector3d refvec '= (centerpoint'-p1'). mormal ();
Vector3d vecz' = vecx'. crossproduct (refvec ');
Vector3d vecy '= vecx'. crossproduct (vecz ');
Matrix3d M1 = new matrix3d ();
M1.setcoordinatesystem (P1 ', vecx', vecy', vecz'); // new transform

Transformation Matrix:

Matrix3d transform = m1 * (m0.invert ());

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.