Monthly Archives: October 2014

Tutorial

Lists...

One of the things that I spend a lot of time doing in Mathematica is creating lists of co-ordinates so that I can export them into structural analysis software, either before or after I've rotated and transformed them through space to mimic a deployable structure.

Most of these methods I've picked up along the way through trawling Stack Exchange which I find a great resource for learning Mathematica, I'm not able to link to all of them as I've hoovered them up into a notebook over a long period of time and not kept all of the original links...

Creating lists.

Frequently I'll create a list of x co-ordinates, then y co-ordinates, then the z co-ordinates.  There are a multitude of ways to do this, a few of the ways to create a list of co-ordinates are linked below:

Other ways of creating lists, could make use of functions.

{0, 2, 4, 6, 8, 10}

{1, 4, 9, 16, 25}

Creating points

And there are dozens of other methods that are available, but once you have your list of x, y, and z co-0rdinates then the next step is to combine them.  You could certainly type them in long hand as below, but the more nodes you have the longer it takes.

You could automate a simple list of co-ordinates like above in a couple of ways:

or

Both return the same list of co-ordinates:

{{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {3, 0, 0}, {4, 0, 0}, {5, 0, 0}}

Combining lists.

Or you might have created a list of points, the same as the lists x,y, and z at the top of this post and now want to combine them...

 Thread.

Thread[ ] is available and is one of the quicker methods for knitting together lists.

{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}

MapThread.

An alternative is  MapThread[ ]

or

both return.

{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}

Transpose.

Transpose[ ]   can be used for nice tidy syntax

Inner.

If there is a simple 2D set of co-ordinates, then these can be combined using  Inner[ ]

Riffle.

Again for simple 2D lists, the function  Riffle[ ] can be used, but needs to be used in combination with  Partition[ ]

If you're working with multiple lists, then a function called multiRiffle can be written, taken from here.

Gives

{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}

 

Custom functions.

If you only have 2D data points then a function could be written to knit them together, these functions can check to see if the lists are of the same length too which can be beneficial.

{{0, 10}, {1, 11}, {2, 12}, {3, 13}, {4, 14}, {5, 15}, {6, 16}}

Which can be adapted for 3D data points easily enough.

{{0, 10, 0}, {1, 11, 1}, {2, 12, 2}, {3, 13, 3}, {4, 14, 4}, {5, 15, 5}, {6, 16, 6}}

Hopefully this will help someone who's learning Mathematica who's going to be working with data points and co-ordinates a lot.  It seems to be a topic that gets asked a lot on Mathematica Stack Exchange so I thought it would be helpful to try and summarise up in one post.

Research Tutorial

Dynamic Arches...

Tinkering about with SystemModeler a little further, I've managed to finally build a sprung arch, complete with dampers on the revolute joints.  I'm intending on using this principle in my research to create folded structures, so it's interesting to see what effect the spring stiffness will have on the behaviour of the arch during the unpacking process - specifically looking at the accelerations on the masses at key points.

The thing that I was struggling with was creating a structure that had a set of equations that could be solved, the key concept I was initially missing was the closing of the structure with the special type of revolute joint to complete the chain.  Without this special revolute chain the equations are essentially unsolvable, so it's important that one of these joints sits in the system somewhere.

Sprung Arch

Another concept is that the structure in the video has 3 straight segments, each 1m long; but the supports are only 2m apart.... forcing the arch to pop into a stable shape that balances the weights at each of the joints.  This is essentially what makes the arch wobble when solving the initial set of equations.  Next step is applying external forces and measurement points along the structure for displacement etc...