Ronan

1267 Reputation

14 Badges

12 years, 278 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@acer  Well it works and is far less torturous than my fisrt approach of having to animate each component of the body seperately.

How would I put in for a software enhacment to improve the situation?

 

@acer Thank you for you helpful insights. I have used your

f:=T->unapply(convert(eval(Q,t=T).Vector(3,[x,y,z]) , list ),  [x,y,z])

There definately room for improvement to transform command to make more like the rotate command.

I created Body2. It is in my worksheet posted at the start.' vv' was just saying that my rotate command as posted worked. I am using it to animate a body tumbling as it rotates about it's mid axis of inertia called the Dzhanibekov effect. A link to the blog on this is posted in a reply to Rouben Rostamain above. Even though it tumbles it's rotational momentum remains constant.

 

 

@Rouben Rostamian   I am following a blog on the Dzhanibekov effect. It starts here http://arkadiusz-jadczyk.eu/blog/2017/01/04/   . He is now getting into using quaternions.

@Kitonum That debugged it. I think the whole thing is a work around though. Not a criticism of you. I guess transfom has to look at a huge array of points that have been stored somewhere and operate on them all. Rotate only needed to inprinciple operate on about a dozen points in the body and the internal routines of arrow, point, line etc fill in the rest. There is definatels scopt for an improved rotate command to take matrices. I know matrices can also transform shape.

@Rouben Rostamian   Well Quaternions definately solve the problem of dismantling an Euler rotation matrix. See it is easy to convert the quaternion to get axis and angle. Have a little bit of familaity with them. Don't fully understand all the details of your worksheet but get the concept.  Nearly fell of my seat when I saw you reply this evening. I am using Eulers euqations of motion applied to a rigid body rotating about it's mid axis of inertia. It tumbles. Will update you soon.

Write that book. You have valuable knowledge.

 

@Scot Gould So do you use worksheet or document mode with 1D math input? I like an example if that is ok.

@Rouben Rostamian  I look forward to your corrected worksheet. What the problem with the one you posted. It pasted my body into it and it ran.

 

@vv Hi. Yes rotate works. The original question was that I have the rotation matrix not the original w1 w2 w3. I just threw in the Euler rotation matrix here as it is easy to produce for this example.

In my reply to you above I tried applying the transform command to the matrix (Rot). That I couldn't get to work. I dont think I did that correctly. I basicially used 

f:=t->plottools:-transform((x,y,z)->convert(Rot.Vector(3,[x,y,z]), list)): 

f2 := plots:-animate(plots:-display, [('f(t)')(Body2)], t = 0 .. 8*Pi, frames = 100, scaling = constrained)

This either produces an empty animation (10 frames)   or output exceeds 10000000   (100 frames) I tried unevaluation quotes around plots:-display.


 

@Kitonum  Tried this.

Either it gives empty plot or for 100 frames `[Length of output exceeds limit of 10000000]`. Tried the usual combinations of delay evaluation quotes. No luck.

f := proc (t) options operator, arrow; transform(proc (x, y, z) options operator, arrow; convert(Rot . Vector(3, [x, y, z]), list) end proc) end proc

f2 := plots:-animate(plots:-display, [('f(t)')(Body2)], t = 0 .. 8*Pi, frames = 100, scaling = constrained)

@Scot Gould  Thanks for the useful info. Yes I know a lot of pros. use the worksheet format. I home thought so started off on the pretty interface.

@vv That make it simple. I confused rotate with the Rotate command in Image tools. It uses lefthand rule. Odd but not a shot stopper.

@acer  Firstly I replyed to this hours ago but it never appeared here. You have masterful insight/experience with Maple. I tested your solutions under the following condition. I replaced, e.g sin(0.25 t) with sin(w t), then defined w later after the display/animate commands. The 'point' produces an error still, 'line' works fine. Worksheet posted, I made before I saw your posts.

      I have included the OriginalBody. I wanted to rotate this without having to define the functions inside the plot/display/animate commands. What I have done works but I certainly don't like the level of workaround required.

restart

with(plots):

with(plottools):

NULL
OriginalBody := display([point([1, -.2, 0], colour = red, symbolsize = 50, symbol = solidsphere), point([-1, -.2, 0], colour = red, symbolsize = 50, symbol = solidsphere), point([0, 1, 0], colour = purple, symbolsize = 50, symbol = solidsphere), line([0, 0, 0], [1, -.2, 0]), line([0, 0, 0], [-1, -.2, 0]), line([0, 0, 0], [0, 1, 0]), line([0, 0, 0], [.5, 0, 0], colour = red, thickness = 4), line([0, 0, 0], [0, .5, 0], colour = yellow, thickness = 4), line([0, 0, 0], [0, 0, .5], colour = blue, thickness = 4)], scaling = constrained)

 

``

``

c1 := Vector(3, [1, -.2, 0]):

c2 := Vector(3, [-1, -.2, 0]):

c3 := Vector(3, [0, 1, 0]):

c4 := Vector(3, [1, -.2, 0]):

c5 := Vector(3, [-1, -.2, 0]):

c6 := Vector(3, [0, 1, 0]):

c7 := Vector(3, [.5, 0, 0]):

c8 := Vector(3, [0, .5, 0]):

c9 := Vector(3, [0, 0, .5]):

c := [seq(c || n, n = 1 .. 9)]

[Vector[column](%id = 18446744074369140486), Vector[column](%id = 18446744074369140606), Vector[column](%id = 18446744074369140726), Vector[column](%id = 18446744074369140846), Vector[column](%id = 18446744074369140966), Vector[column](%id = 18446744074369141086), Vector[column](%id = 18446744074369141206), Vector[column](%id = 18446744074369141326), Vector[column](%id = 18446744074369141446)]

(1)

Rot1 := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = cos(w1*t), (2, 3) = -sin(w1*t), (3, 1) = 0, (3, 2) = sin(w1*t), (3, 3) = cos(w1*t)})

Rot2 := Matrix(3, 3, {(1, 1) = cos(w2*t), (1, 2) = 0, (1, 3) = sin(w2*t), (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = -sin(w2*t), (3, 2) = 0, (3, 3) = cos(w2*t)})

Rot3 := Matrix(3, 3, {(1, 1) = cos(w3*t), (1, 2) = -sin(w3*t), (1, 3) = 0, (2, 1) = sin(w3*t), (2, 2) = cos(w3*t), (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1})

Rot := Rot1.Rot2.Rot3

Matrix(%id = 18446744074369136510)

(2)

d := seq(Rot.c[n], n = 1 .. 9)

Vector[column](%id = 18446744074369118686), Vector[column](%id = 18446744074369118806), Vector[column](%id = 18446744074369118926), Vector[column](%id = 18446744074369119046), Vector[column](%id = 18446744074369119166), Vector[column](%id = 18446744074369119286), Vector[column](%id = 18446744074369119406), Vector[column](%id = 18446744074369119526), Vector[column](%id = 18446744074369119646)

(3)

Bdyprt1 := unapply(display(POINTS([d[1][1], d[1][2], d[1][3]]), colour = red, symbolsize = 50, symbol = solidsphere), t); Bdyprt1a := plots:-animate(Bdyprt1, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt2 := unapply(display(POINTS([d[2][1], d[2][2], d[2][3]]), colour = red, symbolsize = 50, symbol = solidsphere), t); Bdyprt2a := plots:-animate(Bdyprt2, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt3 := unapply(plots:-display(POINTS([d[3][1], d[3][2], d[3][3]]), colour = purple, symbolsize = 50, symbol = solidsphere), t):
NULL
Bdyprt3a := plots:-animate(Bdyprt3, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt4 := unapply(display(line([0, 0, 0], [d[4][1], d[4][2], d[4][3]])), t); Bdyprt4a := plots:-animate(Bdyprt4, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt5 := unapply(display(line([0, 0, 0], [d[5][1], d[5][2], d[5][3]])), t); Bdyprt5a := plots:-animate(Bdyprt5, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt6 := unapply(display(line([0, 0, 0], [d[6][1], d[6][2], d[6][3]])), t); Bdyprt6a := plots:-animate(Bdyprt6, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt7 := unapply(display(line([0, 0, 0], [d[7][1], d[7][2], d[7][3]], colour = red, thickness = 4)), t); Bdyprt7a := plots:-animate(Bdyprt7, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt8 := unapply(display(line([0, 0, 0], [d[8][1], d[8][2], d[8][3]], colour = yellow, thickness = 4)), t); Bdyprt8a := plots:-animate(Bdyprt8, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt9 := unapply(plots:-display(plottools:-line([0, 0, 0], [d[9][1], d[9][2], d[9][3]], colour = blue, thickness = 4)), t):

NULL

NULL

w1 := .35; 1; w2 := .45; 1; w3 := .15

.15

(4)

NULL

``

NULL

``

NULL

plots:-display(Bdyprt1a, Bdyprt2a, Bdyprt3a, Bdyprt4a, Bdyprt5a, Bdyprt6a, Bdyprt7a, Bdyprt8a, Bdyprt9a, scaling = constrained)

 

NULL


 

Download Anim_How-2.mw


 

restart

with(plots):

with(plottools):

NULL
OriginalBody := display([point([1, -.2, 0], colour = red, symbolsize = 50, symbol = solidsphere), point([-1, -.2, 0], colour = red, symbolsize = 50, symbol = solidsphere), point([0, 1, 0], colour = purple, symbolsize = 50, symbol = solidsphere), line([0, 0, 0], [1, -.2, 0]), line([0, 0, 0], [-1, -.2, 0]), line([0, 0, 0], [0, 1, 0]), line([0, 0, 0], [.5, 0, 0], colour = red, thickness = 4), line([0, 0, 0], [0, .5, 0], colour = yellow, thickness = 4), line([0, 0, 0], [0, 0, .5], colour = blue, thickness = 4)], scaling = constrained)

 

``

``

c1 := Vector(3, [1, -.2, 0]):

c2 := Vector(3, [-1, -.2, 0]):

c3 := Vector(3, [0, 1, 0]):

c4 := Vector(3, [1, -.2, 0]):

c5 := Vector(3, [-1, -.2, 0]):

c6 := Vector(3, [0, 1, 0]):

c7 := Vector(3, [.5, 0, 0]):

c8 := Vector(3, [0, .5, 0]):

c9 := Vector(3, [0, 0, .5]):

c := [seq(c || n, n = 1 .. 9)]

[Vector[column](%id = 18446744074369140486), Vector[column](%id = 18446744074369140606), Vector[column](%id = 18446744074369140726), Vector[column](%id = 18446744074369140846), Vector[column](%id = 18446744074369140966), Vector[column](%id = 18446744074369141086), Vector[column](%id = 18446744074369141206), Vector[column](%id = 18446744074369141326), Vector[column](%id = 18446744074369141446)]

(1)

Rot1 := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = cos(w1*t), (2, 3) = -sin(w1*t), (3, 1) = 0, (3, 2) = sin(w1*t), (3, 3) = cos(w1*t)})

Rot2 := Matrix(3, 3, {(1, 1) = cos(w2*t), (1, 2) = 0, (1, 3) = sin(w2*t), (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = -sin(w2*t), (3, 2) = 0, (3, 3) = cos(w2*t)})

Rot3 := Matrix(3, 3, {(1, 1) = cos(w3*t), (1, 2) = -sin(w3*t), (1, 3) = 0, (2, 1) = sin(w3*t), (2, 2) = cos(w3*t), (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1})

Rot := Rot1.Rot2.Rot3

Matrix(%id = 18446744074369136510)

(2)

d := seq(Rot.c[n], n = 1 .. 9)

Vector[column](%id = 18446744074369118686), Vector[column](%id = 18446744074369118806), Vector[column](%id = 18446744074369118926), Vector[column](%id = 18446744074369119046), Vector[column](%id = 18446744074369119166), Vector[column](%id = 18446744074369119286), Vector[column](%id = 18446744074369119406), Vector[column](%id = 18446744074369119526), Vector[column](%id = 18446744074369119646)

(3)

Bdyprt1 := unapply(display(POINTS([d[1][1], d[1][2], d[1][3]]), colour = red, symbolsize = 50, symbol = solidsphere), t); Bdyprt1a := plots:-animate(Bdyprt1, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt2 := unapply(display(POINTS([d[2][1], d[2][2], d[2][3]]), colour = red, symbolsize = 50, symbol = solidsphere), t); Bdyprt2a := plots:-animate(Bdyprt2, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt3 := unapply(plots:-display(POINTS([d[3][1], d[3][2], d[3][3]]), colour = purple, symbolsize = 50, symbol = solidsphere), t):
NULL
Bdyprt3a := plots:-animate(Bdyprt3, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt4 := unapply(display(line([0, 0, 0], [d[4][1], d[4][2], d[4][3]])), t); Bdyprt4a := plots:-animate(Bdyprt4, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt5 := unapply(display(line([0, 0, 0], [d[5][1], d[5][2], d[5][3]])), t); Bdyprt5a := plots:-animate(Bdyprt5, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt6 := unapply(display(line([0, 0, 0], [d[6][1], d[6][2], d[6][3]])), t); Bdyprt6a := plots:-animate(Bdyprt6, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt7 := unapply(display(line([0, 0, 0], [d[7][1], d[7][2], d[7][3]], colour = red, thickness = 4)), t); Bdyprt7a := plots:-animate(Bdyprt7, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt8 := unapply(display(line([0, 0, 0], [d[8][1], d[8][2], d[8][3]], colour = yellow, thickness = 4)), t); Bdyprt8a := plots:-animate(Bdyprt8, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt9 := unapply(plots:-display(plottools:-line([0, 0, 0], [d[9][1], d[9][2], d[9][3]], colour = blue, thickness = 4)), t):

NULL

NULL

w1 := .35; 1; w2 := .45; 1; w3 := .15

.15

(4)

NULL

``

NULL

``

NULL

plots:-display(Bdyprt1a, Bdyprt2a, Bdyprt3a, Bdyprt4a, Bdyprt5a, Bdyprt6a, Bdyprt7a, Bdyprt8a, Bdyprt9a, scaling = constrained)

 

NULL


 

Download Anim_How-2.mw

@acer Very insightful. Points still can cause errors with you solutions if a variable apart from t does not have a numerical value. Line works fine.  I got this working last night using POINTS. My approach is somewhat tedious to program. I would rather be able to apply the rotation matrix to the "OriginalBody" shoun at the start.

restart

with(plots):

with(plottools):

NULL
OriginalBody := display([point([1, -.2, 0], colour = red, symbolsize = 50, symbol = solidsphere), point([-1, -.2, 0], colour = red, symbolsize = 50, symbol = solidsphere), point([0, 1, 0], colour = purple, symbolsize = 50, symbol = solidsphere), line([0, 0, 0], [1, -.2, 0]), line([0, 0, 0], [-1, -.2, 0]), line([0, 0, 0], [0, 1, 0]), line([0, 0, 0], [.5, 0, 0], colour = red, thickness = 4), line([0, 0, 0], [0, .5, 0], colour = yellow, thickness = 4), line([0, 0, 0], [0, 0, .5], colour = blue, thickness = 4)], scaling = constrained)

 

``

``

c1 := Vector(3, [1, -.2, 0]):

c2 := Vector(3, [-1, -.2, 0]):

c3 := Vector(3, [0, 1, 0]):

c4 := Vector(3, [1, -.2, 0]):

c5 := Vector(3, [-1, -.2, 0]):

c6 := Vector(3, [0, 1, 0]):

c7 := Vector(3, [.5, 0, 0]):

c8 := Vector(3, [0, .5, 0]):

c9 := Vector(3, [0, 0, .5]):

c := [seq(c || n, n = 1 .. 9)]

[Vector[column](%id = 18446744074369140486), Vector[column](%id = 18446744074369140606), Vector[column](%id = 18446744074369140726), Vector[column](%id = 18446744074369140846), Vector[column](%id = 18446744074369140966), Vector[column](%id = 18446744074369141086), Vector[column](%id = 18446744074369141206), Vector[column](%id = 18446744074369141326), Vector[column](%id = 18446744074369141446)]

(1)

Rot1 := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = cos(w1*t), (2, 3) = -sin(w1*t), (3, 1) = 0, (3, 2) = sin(w1*t), (3, 3) = cos(w1*t)})

Rot2 := Matrix(3, 3, {(1, 1) = cos(w2*t), (1, 2) = 0, (1, 3) = sin(w2*t), (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = -sin(w2*t), (3, 2) = 0, (3, 3) = cos(w2*t)})

Rot3 := Matrix(3, 3, {(1, 1) = cos(w3*t), (1, 2) = -sin(w3*t), (1, 3) = 0, (2, 1) = sin(w3*t), (2, 2) = cos(w3*t), (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1})

Rot := Rot1.Rot2.Rot3

Matrix(%id = 18446744074369136510)

(2)

d := seq(Rot.c[n], n = 1 .. 9)

Vector[column](%id = 18446744074369118686), Vector[column](%id = 18446744074369118806), Vector[column](%id = 18446744074369118926), Vector[column](%id = 18446744074369119046), Vector[column](%id = 18446744074369119166), Vector[column](%id = 18446744074369119286), Vector[column](%id = 18446744074369119406), Vector[column](%id = 18446744074369119526), Vector[column](%id = 18446744074369119646)

(3)

Bdyprt1 := unapply(display(POINTS([d[1][1], d[1][2], d[1][3]]), colour = red, symbolsize = 50, symbol = solidsphere), t); Bdyprt1a := plots:-animate(Bdyprt1, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt2 := unapply(display(POINTS([d[2][1], d[2][2], d[2][3]]), colour = red, symbolsize = 50, symbol = solidsphere), t); Bdyprt2a := plots:-animate(Bdyprt2, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt3 := unapply(plots:-display(POINTS([d[3][1], d[3][2], d[3][3]]), colour = purple, symbolsize = 50, symbol = solidsphere), t):
NULL
Bdyprt3a := plots:-animate(Bdyprt3, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt4 := unapply(display(line([0, 0, 0], [d[4][1], d[4][2], d[4][3]])), t); Bdyprt4a := plots:-animate(Bdyprt4, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt5 := unapply(display(line([0, 0, 0], [d[5][1], d[5][2], d[5][3]])), t); Bdyprt5a := plots:-animate(Bdyprt5, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt6 := unapply(display(line([0, 0, 0], [d[6][1], d[6][2], d[6][3]])), t); Bdyprt6a := plots:-animate(Bdyprt6, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt7 := unapply(display(line([0, 0, 0], [d[7][1], d[7][2], d[7][3]], colour = red, thickness = 4)), t); Bdyprt7a := plots:-animate(Bdyprt7, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt8 := unapply(display(line([0, 0, 0], [d[8][1], d[8][2], d[8][3]], colour = yellow, thickness = 4)), t); Bdyprt8a := plots:-animate(Bdyprt8, [t], t = 0 .. 8*Pi, frames = 100)

Bdyprt9 := unapply(plots:-display(plottools:-line([0, 0, 0], [d[9][1], d[9][2], d[9][3]], colour = blue, thickness = 4)), t):

NULL

NULL

w1 := .35; 1; w2 := .45; 1; w3 := .15

.15

(4)

NULL

``

NULL

``

NULL

plots:-display(Bdyprt1a, Bdyprt2a, Bdyprt3a, Bdyprt4a, Bdyprt5a, Bdyprt6a, Bdyprt7a, Bdyprt8a, Bdyprt9a, scaling = constrained)

 

NULL


 

Download Anim_How-2.mw

 

@Kitonum  Hi, I was looking for a way not to directly place the transformation formulas inside the plot function. This is what post question was about.

@vv Thank you. Wouldn't have thought of that. Any idea whay that works. Now it won't work for a point. Any Idea on that?

ff := unapply(display(point([d[1][1], d[1][2], d[1][3]], colour = red, symbolsize = 50, symbol = solidsphere)), t)

Error, (in plottools:-point) incorrect arguments for creating points structure, try providing the dimension option
 

First 23 24 25 26 27 28 29 Page 25 of 30