MTs, WM2D, and WM Basic Language Script Code
Moderator: scott
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
When I work out the point geometry for the simulations, I find myself using 3 basic tools over and over again.
Pythagorean threrum
Vector Components
Arctangent
Depending on what variables you know, sometimes you have to use two tools to find what you need.
WM2D doesn't give you an arcsine or arccosine function, but usually arctangent is good enough. Only on MT24 and MT25 I wished I had an arccosine or arcsine function to use in conjunction with the law of sines or the law of cosines, but usually everything can be broken down into right triangles.
Pythagorean threrum
Vector Components
Arctangent
Depending on what variables you know, sometimes you have to use two tools to find what you need.
WM2D doesn't give you an arcsine or arccosine function, but usually arctangent is good enough. Only on MT24 and MT25 I wished I had an arccosine or arcsine function to use in conjunction with the law of sines or the law of cosines, but usually everything can be broken down into right triangles.
re: MTs, WM2D, and WM Basic Language Script Code
Pythagoras:
a² + b² = c²
(c·Cos θ)² + (c·Sin θ)² = c²
b/a = Tan θ = (c·Sin θ) / (c·Cos θ)
For an ArcSin you can use the Arctan function.
You either need the perpendicular vector a, or you can calculate that one via Pythagoras. But then you need to know the magnitude 'c' (maybe gravity G).
Thus from Pythagoras we can infer: a = √ (c²- b²)
Now we can create an ArcSin function ourselves:
From the equation Tan θ=b/a, and the arcTan function we can now infer that:
arcsin(b) = atan(b/a) = atan2(b,a) = atan2(b,sqrt(c^2-b^2) )
When c is a unit vector, as is usually required, then it's slightly simpler: arcsin b = atan(b/sqrt(1-b^2)) = atan2(b,sqrt(1-b^2))
I think/hope WM2D has the atan2() function (two parameters).
It causes the resulting angle to be found in the full quadrant range [-Pi .. +Pi], instead of just [-Pi/2..+Pi/2] with a single parameter. (not that it actually helps for an ArcSin function)
To complete, the ArcCos is just swapped:
arccos(a) = atan(b/a) = atan2(b,a) = atan2(sqrt(c^2-a^2),a )
Hope it helps.
ETA: Perhaps it's too short of an explanation. When you need an example, just ask.
a² + b² = c²
(c·Cos θ)² + (c·Sin θ)² = c²
b/a = Tan θ = (c·Sin θ) / (c·Cos θ)
For an ArcSin you can use the Arctan function.
You either need the perpendicular vector a, or you can calculate that one via Pythagoras. But then you need to know the magnitude 'c' (maybe gravity G).
Thus from Pythagoras we can infer: a = √ (c²- b²)
Now we can create an ArcSin function ourselves:
From the equation Tan θ=b/a, and the arcTan function we can now infer that:
arcsin(b) = atan(b/a) = atan2(b,a) = atan2(b,sqrt(c^2-b^2) )
When c is a unit vector, as is usually required, then it's slightly simpler: arcsin b = atan(b/sqrt(1-b^2)) = atan2(b,sqrt(1-b^2))
I think/hope WM2D has the atan2() function (two parameters).
It causes the resulting angle to be found in the full quadrant range [-Pi .. +Pi], instead of just [-Pi/2..+Pi/2] with a single parameter. (not that it actually helps for an ArcSin function)
To complete, the ArcCos is just swapped:
arccos(a) = atan(b/a) = atan2(b,a) = atan2(sqrt(c^2-a^2),a )
Hope it helps.
ETA: Perhaps it's too short of an explanation. When you need an example, just ask.
Marchello E.
-- May the force lift you up. In case it doesn't, try something else.---
-- May the force lift you up. In case it doesn't, try something else.---
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
Thanks Marchello.
If I come across it again, ...
If I come across it again, ...
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
Draw Ring - Version 4
Was fiddling with the ring code. Updated the dialog box to include: Mass, Static Friction, Kinetic Friction and Elasticity.
Was fiddling with the ring code. Updated the dialog box to include: Mass, Static Friction, Kinetic Friction and Elasticity.
- Attachments
-
- Draw_Ring_V4.txt
- Draw Ring Version 4 - Basic Language script code that will draw a ring, or hollow polygon with from 3 to 360 sides
- (14.23 KiB) Downloaded 66 times
Last edited by Wubbly on Tue Sep 03, 2019 1:20 am, edited 1 time in total.
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
MT-09 Version 4
Was fiddling with the MT09 simulation. The previous version didn't let you input parameters for the geometry. The radius was fixed at 1 meter and the length of the rod was fixed by the polygon geometry.
This version gives you a dialog box where you can enter various parameters. It gives you more control of the build dimensions and you are not limited to only 8 weights. The downside is that you can only connect opposite weights with pulleys.
The previous versions didn't run, and this one runs about the same.
Was fiddling with the MT09 simulation. The previous version didn't let you input parameters for the geometry. The radius was fixed at 1 meter and the length of the rod was fixed by the polygon geometry.
This version gives you a dialog box where you can enter various parameters. It gives you more control of the build dimensions and you are not limited to only 8 weights. The downside is that you can only connect opposite weights with pulleys.
The previous versions didn't run, and this one runs about the same.
- Attachments
-
- MT09_V4_Simulation.TXT
- MT-09 V4 Simulation - Basic Language script code that will build a variant of an MT-09
- (35.02 KiB) Downloaded 60 times
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
Attached is the geometry for the MT09 V4 simulation.
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
MT-11 Version 2
The dialog box for the MT-11 simulation has been updated to include various inputs. This gives the user control over the dimensions of the build. In the previous version, many of these inputs were set at some fixed value that could not be changed.
The user can input:
R1 - The distance to the rod pivot point for the inner weights (cm)
R2 - The distance to the rod pivot point for the outer weights (cm)
M1 - mass of each inner weight (kg)
M2 - mass of each outer weight (kg)
D - Rod length (cm)
... and a few other parameters.
Changed the masses to kilograms instead of grams, but left lengths in centimeters. The input sliders for mass didn't like the ranges I was trying to set and they kept setting the lower bound to 1, but in the [kg] range they would let me set the correct lower bound. And then decided to change several of the input sliders to textbox inputs. This gives the user more control over their values.
Angle "D" from a previous post in this thread is used. Thanks Mick! It was converted to radians for convenience. It's the variable "a4" in the simulation.
The point geometry drawing is not to scale. Inner and Outer weights have very similar geometry so I mirrored the quadrant in ACAD to save drawing time, but WM2D draws it correctly.
Finally figured out how to put an Output Meter on the drawing using the script, so an output meter has been added to show angular velocity of the background wheel. It draws a straight line until you turn off the motor.
Feels like every inch I move forward I have to run a mile. Reminded me of this song:
... get there when we get there, every inch is a mile ...
https://www.youtube.com/watch?v=m8LFyU_FdXU
I guess if you build enough of these gravity only simulations, you come to the conclusion that none are workable. I haven't quite come to that conclusion yet. Maybe someday I'll get there.
The dialog box for the MT-11 simulation has been updated to include various inputs. This gives the user control over the dimensions of the build. In the previous version, many of these inputs were set at some fixed value that could not be changed.
The user can input:
R1 - The distance to the rod pivot point for the inner weights (cm)
R2 - The distance to the rod pivot point for the outer weights (cm)
M1 - mass of each inner weight (kg)
M2 - mass of each outer weight (kg)
D - Rod length (cm)
... and a few other parameters.
Changed the masses to kilograms instead of grams, but left lengths in centimeters. The input sliders for mass didn't like the ranges I was trying to set and they kept setting the lower bound to 1, but in the [kg] range they would let me set the correct lower bound. And then decided to change several of the input sliders to textbox inputs. This gives the user more control over their values.
Angle "D" from a previous post in this thread is used. Thanks Mick! It was converted to radians for convenience. It's the variable "a4" in the simulation.
The point geometry drawing is not to scale. Inner and Outer weights have very similar geometry so I mirrored the quadrant in ACAD to save drawing time, but WM2D draws it correctly.
Finally figured out how to put an Output Meter on the drawing using the script, so an output meter has been added to show angular velocity of the background wheel. It draws a straight line until you turn off the motor.
Feels like every inch I move forward I have to run a mile. Reminded me of this song:
... get there when we get there, every inch is a mile ...
https://www.youtube.com/watch?v=m8LFyU_FdXU
I guess if you build enough of these gravity only simulations, you come to the conclusion that none are workable. I haven't quite come to that conclusion yet. Maybe someday I'll get there.
- Attachments
-
- MT11_V2 Simulation.txt
- MT-11 V2 Simulation - Basic Language script code that will build the model in WM2D
- (42.95 KiB) Downloaded 72 times
re: MTs, WM2D, and WM Basic Language Script Code
Hi Wubbly
You are doing some impressive work.
Regards
You are doing some impressive work.
Regards
[MP] Mobiles that perpetuate - external energy allowed
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
Everyone seems to have an opinion about the Toy's page, so here's my take on it.
Take the hammermen toy, remove the hammermen, put weights where the handles are, and pin the two middle rectangles to a background wheel.
You basically have a parallelogram with two extended sides containing weights on their ends.
Take the hammermen toy, remove the hammermen, put weights where the handles are, and pin the two middle rectangles to a background wheel.
You basically have a parallelogram with two extended sides containing weights on their ends.
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
MT-141
Here's a simulation of my interpretation of MT141.
Had a terrible time getting this one to run. Kept getting constraint errors a few revolutions after the motor was turned off. Had to fiddle with the Accuracy settings and the more accurate I set it, the less often constraint errors happened. I think it had something to do with my stop mass, or maybe the way I was pinning bodies. Finally I changed the stop mass connection from a square joint to a pin joint and it significantly reduced the constraint errors.
If you run the model and suddenly your geometry flies off into infinity, don't be surprised.
I made this one "Model A". The next iteration of MT-141 will be Model B with a slightly different geometry and hopefully less constraint errors.
Somehow I expected more from this one. It didn't run anything like I expected it to in my head. Another disappointment. But failure is success if you learn from it.
Here's a simulation of my interpretation of MT141.
Had a terrible time getting this one to run. Kept getting constraint errors a few revolutions after the motor was turned off. Had to fiddle with the Accuracy settings and the more accurate I set it, the less often constraint errors happened. I think it had something to do with my stop mass, or maybe the way I was pinning bodies. Finally I changed the stop mass connection from a square joint to a pin joint and it significantly reduced the constraint errors.
If you run the model and suddenly your geometry flies off into infinity, don't be surprised.
I made this one "Model A". The next iteration of MT-141 will be Model B with a slightly different geometry and hopefully less constraint errors.
Somehow I expected more from this one. It didn't run anything like I expected it to in my head. Another disappointment. But failure is success if you learn from it.
- Attachments
-
- MT141_ModelA_V1 Sim.TXT
- MT-141 Model A V1 Simulation - Basic Language script code that will build the model in WM2D
- (36.53 KiB) Downloaded 67 times
re: MTs, WM2D, and WM Basic Language Script Code
Yes, sometimes changing out pins for rigid joints helps a lot. And you've done about everything else I'd try.
Sometimes there are just too many parts in a sim, and it crashes (explodes) etc. I'm dealing with that right now fwiw.
The only thing I can do is keep trying to simplify the design further and further, to the least number of parts possible. And that includes rods etc.
Tried a couple of tricks today for latches. Used a rope connection (can use rod). Got an Output of the Y position of a weight and when it was above that y point the rope was OFF, when below ON.
Just put an IF statement in the Active When. The difference this time was that I had two going at once and it didn't crash this time.
If I used the rigid joint with an ON/OFF procedure same as above, crashed immediately or wouldn't work at all.
Sometimes there are just too many parts in a sim, and it crashes (explodes) etc. I'm dealing with that right now fwiw.
The only thing I can do is keep trying to simplify the design further and further, to the least number of parts possible. And that includes rods etc.
Tried a couple of tricks today for latches. Used a rope connection (can use rod). Got an Output of the Y position of a weight and when it was above that y point the rope was OFF, when below ON.
Just put an IF statement in the Active When. The difference this time was that I had two going at once and it didn't crash this time.
If I used the rigid joint with an ON/OFF procedure same as above, crashed immediately or wouldn't work at all.
re: MTs, WM2D, and WM Basic Language Script Code
Wubbly, You're doing a great job here. It's a lot of work.
I had this interesting encounter with the Calloway simulation.
Whenever I made changes to the pendulums in edit-mode, the sliding weights (not touching the pendulum) with rigid slot joints all got haywire and got moved somewhere else and rearranged in some undesigned and undesired orientation. It isn't even an enormous amount of components.
Usually you can get away with temporarily lock all the stuff into place for restricting the reorientation attempt, and hope for the best. Not in this case. :-\
Basically that's a benefit when creating a model via programming: It's simple to start over... At least when you didn't forget to save it in a good place before a crash happens :-D
Also, thanks for: https://www.besslerwheel.com/forum/view ... 559#169559
I had this interesting encounter with the Calloway simulation.
Whenever I made changes to the pendulums in edit-mode, the sliding weights (not touching the pendulum) with rigid slot joints all got haywire and got moved somewhere else and rearranged in some undesigned and undesired orientation. It isn't even an enormous amount of components.
Usually you can get away with temporarily lock all the stuff into place for restricting the reorientation attempt, and hope for the best. Not in this case. :-\
Basically that's a benefit when creating a model via programming: It's simple to start over... At least when you didn't forget to save it in a good place before a crash happens :-D
Also, thanks for: https://www.besslerwheel.com/forum/view ... 559#169559
Marchello E.
-- May the force lift you up. In case it doesn't, try something else.---
-- May the force lift you up. In case it doesn't, try something else.---
- Wubbly
- Aficionado
- Posts: 727
- Joined: Sat Jun 06, 2009 2:15 am
- Location: A small corner of the Milky Way Galaxy
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
I ran across a similar problem with rigid joints and MT24 Version 0. If I turned the motor off before starting the simulation, all the spokes reoriented to the horizontal.
If the wheel is oriented at 0 degrees, and the spoke is oriented at 45 degrees, and if the square joints on each body are oriented at zero degrees, then sometimes it would cause the above problem. I had to orient the joint on the spoke at -45 degrees to fix the problem. Each spoke had to have it's rigid joint oriented opposite it's body's orientation to orient correctly with the 0 degree wheel. Don't know if you would have the same problem is you used the user interface for entry. I don't think I came across that problem with pin joints.
If the wheel is oriented at 0 degrees, and the spoke is oriented at 45 degrees, and if the square joints on each body are oriented at zero degrees, then sometimes it would cause the above problem. I had to orient the joint on the spoke at -45 degrees to fix the problem. Each spoke had to have it's rigid joint oriented opposite it's body's orientation to orient correctly with the 0 degree wheel. Don't know if you would have the same problem is you used the user interface for entry. I don't think I came across that problem with pin joints.
re: MTs, WM2D, and WM Basic Language Script Code
In case you haven't come across this before. One thing to remember using edit mode (allow in progress editing in preferences) is that once the sim is run again the parts retain their velocities when you paused the sim to edit it.
That's ok if you're looking at design etc, but if you are after some kinetic output then you probably should zero out the velocities by hand. I do that by selecting each part and opening >windows>properties. Then zero out Vx, Vy, and Vtotal. When the sim is run again there is no residual velocities (momentum etc).
That's ok if you're looking at design etc, but if you are after some kinetic output then you probably should zero out the velocities by hand. I do that by selecting each part and opening >windows>properties. Then zero out Vx, Vy, and Vtotal. When the sim is run again there is no residual velocities (momentum etc).
-
- Devotee
- Posts: 1718
- Joined: Fri Nov 07, 2003 12:22 pm
- Location: Speyer, Germany
- Contact:
re: MTs, WM2D, and WM Basic Language Script Code
Hi Wubbly,
i have taken a part of you Picture and I have also Extended it.
when you have a look to the original drawing then you see that there are 2 borders, moveable borders, represented by chains.
So the Parallelogram can Switch from one state to the other.
This will always happen if the borders are to Close together.
a chain behaves like a tense arch.
So you have an oscillator driven by gravity.
A function as under stress by gravity.
i have taken a part of you Picture and I have also Extended it.
when you have a look to the original drawing then you see that there are 2 borders, moveable borders, represented by chains.
So the Parallelogram can Switch from one state to the other.
This will always happen if the borders are to Close together.
a chain behaves like a tense arch.
So you have an oscillator driven by gravity.
A function as under stress by gravity.
Best regards
Georg
Georg