cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Rotate around arbitary-axis in 3-D ?

lvl107
20-Turquoise

Rotate around arbitary-axis in 3-D ?

Hi, Everyone.
From the following:

I.PNG

II.PNG

 

The Question 1: How to Rotate A around BC-axis with angle t ?
The Question 2: How to Rotate B around CD-axis with angle t ?

 

Thanks in advance for your time and help.
Best Regards.
Loi.

 

29 REPLIES 29
Werner_E
24-Ruby V
(To:lvl107)

Look for yourself

https://tinyurl.com/3s87jv48

I'd suggest using homogenous coordinates (quaternions) as with them you can describe a translation by a multiplication with a matrix.

lvl107
20-Turquoise
(To:Werner_E)

   Many thanks, Ppal amd Werner. The following: the question 1 was solved.

III.PNG

 

Best Regards.
Loi.

Hi,

Here is a file from earlier on the community.

It has a function that uses quaternions to do the rotation.

ttokoro
20-Turquoise
(To:lvl107)

image.png

lvl107
20-Turquoise
(To:ttokoro)

Oh !... Yeah..., Ttokoro. And how to correct that program function ?

IV.PNG

Best Regards.

Loi.

Werner_E
24-Ruby V
(To:lvl107)


@lvl107 wrote:

Oh !... Yeah..., Ttokoro. And how to correct that program function ?


Don't repair something if it's not broken. There is no need to repair anything, but there is the need to use the function in a correct way 😉

You must pay attention to the orientation of the rotation axis, because this decides in which direction of rotation the angle is measured!

Werner_E_0-1666343577920.png

And of course changing the orientation of the axis is equivalent to changing the sign (direction of rotation) of the angle, as could be seen in ttokoros picture.

 

The function "rotate" is written so that when you look from the "endpoint" (the third function argument) the angle is measured counterclockwise (mathematical positive).

 

One additional remark: Mathcad returns an angle of about 138° for acos(-sqrt 5 /3), but cos(-138,..°) is -sqrt 5 /3 as well 🙂

acos is made a unique function only artificially by using the principal value

Werner_E_1-1666347507907.png

 

 

lvl107
20-Turquoise
(To:Werner_E)

Many thanks, Werner.
From the following:
V.PNG


How to rotate ΔABC about BC-axis by angle φ := acos( - sqrt(5)/3 ) ? and so on ...


Thanks in advance for your time and help.
Best Regards.
Loi.

Werner_E
24-Ruby V
(To:lvl107)

You have a function which can rotate one point around an axis. You should be able yourself to apply this function three times in a row to rotate an arbitrary triangle about an axis.

In your case of rotating ABC about BC is suffices to rotate A as B and C won't move at all 😉

lvl107
20-Turquoise
(To:Werner_E)

   I guess my question is not clear, Werner 😥, I mean tri-ABC as the following:

VI.PNG

   Best Regards.

      Loi.

 

Werner_E
24-Ruby V
(To:lvl107)

"rotate" is function which returns a single point only, The first function argument must be a 3x1 vector and nothing else!

If you want to rotate a structure like the one you tried to feed as function argument, you will have to write your own function to do so. This function would run through the point list you provide, extract on point after the other, call "rotate" for every point and assemble the result in the desired structure again

lvl107
20-Turquoise
(To:Werner_E)

8.PNG

  

  And could I repair something? Just add: [Control]+[-] (vectorize), and I'm still not sure that it's right or not.

9.PNG

10.PNG

   Best Regards.

       Loi.

Werner_E
24-Ruby V
(To:lvl107)

Again: "rotate" is written to work for just one single point, given as a 3x1 matrix an this is what it does.

To rotate a nested structure like the one you provide would need a new, different function which can handle this structure. The new function must cycle to your point structure and apply the rotation for each point one after the other (it may but mnust not use the original "rotate" function for doing so). Simply using vectorize on the original "rotate" function cannot work.

lvl107
20-Turquoise
(To:Werner_E)

  I'm so sorry, Werner. 😥 my program function rotate_vectorize( P , A, B, phi ) was failed as the following:

11.PNG

 I hope we would find an other program function to solve for P is a nest,

    Best Regards.

      Loi.

Werner_E
24-Ruby V
(To:lvl107)

I was surprised that your function did not throw an error right ahead and that it seem to even return correct result in some cases.

As already written, I don't think that simple vectorization can do the job. You would rather have to cycle through your list of points using a loop (for), extract the coordinates of each point, rotate it and put it back in a data structure of the same type as the input.

Guess it could not be done in just three lines of code 😉

lvl107
20-Turquoise
(To:Werner_E)

     Werner, if I just want to rotate triangle-ABC-shape ( three nest element of column vector ) about its bottom-side by an angle acos(-sqrt(5)/3) then I have to do a lot steps (extract the coordinates of each point, rotate it and put it back in a data structure of the same type as the input.) . Some steps of job need do "by hand". I did it as the following:

12.PNG

Best Regards.
Loi.

Werner_E
24-Ruby V
(To:lvl107)

As already written - you will need to program for-loops to automate the process and avoid copy&paste.

I had posted some routines you can take as a template for your own inspiration some weeks ago with an animation showing the construction of a dodecahedron.

The same utility functions can also be used to create an icosahedron.

Werner_E_0-1666576198747.png

Concerning rotating the points in a nested structure you may have a look at "rotate3D( )" - maybe it does what you are looking for or can be modified by you so it does it.

 

 

lvl107
20-Turquoise
(To:Werner_E)

Many thanks, Werner. I'll take a look at "rotate3D( )".
At first sight with the figure below:

I.PNG

I have a query: How to plot "Iko" inscibe "Dodeka" ? or a similar as the below:

II.png

 

Thanks in advance for your time and help.
Best Regards.
Loi.

 

Werner_E
24-Ruby V
(To:lvl107)


@lvl107 wrote:

Many thanks, Werner. I'll take a look at "rotate3D( )".

Good luck! Attached is a replacement for "rotate" which can deal with some sort of nested structures, too. But I guess that "rotate3D()" is more generic.

 


I have a query: How to plot "Iko" inscibe "Dodeka" ?

As can be seen by your pic you already succeeded in doing so.

lvl107
20-Turquoise
(To:Werner_E)


@Werner_E wrote:

 

Good luck! Attached is a replacement for "rotate" which can deal with some sort of nested structures, too. But I guess that "rotate3D()" is more generic.
I guess my hope: " I hope we would find an other program function to solve for P is a nest " come true, Werner.:
Guess it could not be done in just three lines of code lvl107_0-1666739753782.png

( But it could be done in fourteen lines of code 🤔 )

13.PNG14.PNG
Many thanks, again. But I still have a query: How to loop triangle-ABC into nine more remain triangles by program function ? In other words: How to rotate triangle-ABC by an angle [phi] in nine times by program function ?  ( see the above ). 
Best Regards.

 


 


 

lvl107
20-Turquoise
(To:lvl107)

15.PNG

16.PNG

17.PNG

18.PNG

lvl107
20-Turquoise
(To:Werner_E)

1.PNG

2.PNG

lvl107
20-Turquoise
(To:lvl107)

1.PNG

2.PNG

ttokoro
20-Turquoise
(To:lvl107)

image.pngimage.pngimage.png

lvl107
20-Turquoise
(To:lvl107)

1.PNG

2.PNG

lvl107
20-Turquoise
(To:lvl107)

3.PNG

4.PNG

lvl107
20-Turquoise
(To:lvl107)

1.PNG

2.PNG

lvl107
20-Turquoise
(To:lvl107)

1.PNG

2.PNG

3.PNG

4.PNG

5.PNG

lvl107
20-Turquoise
(To:lvl107)

1.PNG

2.PNG

3.PNG

4.PNG

Top Tags