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

19-Tanzanite

Rotate around arbitary-axis in 3-D ?

Hi, Everyone.
From the following:

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 ?

Best Regards.
Loi.

29 REPLIES 29
17-Peridot
(To:lvl107)
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.

19-Tanzanite
(To:Werner_E)

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

Best Regards.
Loi.

21-Topaz I
(To:lvl107)

Hi,

Here is a file from earlier on the community.

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

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:ttokoro)

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

Best Regards.

Loi.

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!

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

19-Tanzanite
(To:Werner_E)

Many thanks, Werner.
From the following:

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

Best Regards.
Loi.

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 😉

19-Tanzanite
(To:Werner_E)

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

Best Regards.

Loi.

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

19-Tanzanite
(To:Werner_E)

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

Best Regards.

Loi.

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.

19-Tanzanite
(To:Werner_E)

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

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

Best Regards.

Loi.

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 😉

19-Tanzanite
(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:

Best Regards.
Loi.

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.

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.

19-Tanzanite
(To:Werner_E)

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

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

Best Regards.
Loi.

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.

19-Tanzanite
(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

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

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.

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:Werner_E)

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:lvl107)

19-Tanzanite
(To:lvl107)

Announcements