Tag Archives: Programming



Mathematica is perfect for working with lists and matrices.  Essentially making it useful for defining and manipulating geometry through rotations and later on analysing the forces through stiffness methods.

A key task when working with series of co-ordinates is to check that the relative distances between points don't change so that the structural elements in between remain the same, even though the structure may have changed position and shape.  When you're working with Mathematica and there's a task that you need to do repeatedly it's often worth creating a custom function that can be called whenever needed.

A couple of the functions that I've written can determine the distance between each co-ordinate in a list for 2D and 3D co-ordinate lists.

First, create some co-ordinates to work with on the examples.

Now that we've got some points to work with we can create a function to determine the distance between the points in 2D.  On 2D points, Mathematica has an inbuilt function called  EuclideanDistance[] which is nice and fast when determining the distance between 2D points.

There are two key parts to the function, the first part maps a list of points across the   EuclideanDistance[] function, with the second section essentially iterating the co-ordinates to restructure the list so that the function can be mapped across the list by rearranging it in a  (First point, Second point)(Second point, Third point) format.... until the last element in the list.

This is nice and zippy for 2D co-ordinates, but won't work unfortunately for 3D and needs modifying to make use of the inbuilt function  Norm[] .

Running a comparison on speed for how 2D points are handled can be compared by zeroing out the Z ordinate.

As can be seen, EuclideanDistance[] is faster, but Norm[] is more flexible and can be used on 2D and 3D co-ordinates.



I'm spending a lot of my time tinkering in Mathematica lately, with two objectives really.

1.) I want to write some code to calculate the tedious geometrical aspects for me for my research.

2.) I think that Mathematica has some real potential for students who are trying to learn structures, particularly through the CDF files.

I've learned various programming languages over the years most of which I've taught myself, admittedly not to the level that perhaps a computer programmer would, but I've armed myself with just enough knowledge to be dangerous and get the task done that I want to achieve.  I've created countless spreadsheets that can do all sorts of elaborate calculations and also to use as validation calculations for more complex analysis models that I've created.

111:365 - Clever Clogs...

This is a skill that I take for granted for engineers, particularly of my age, and in most engineers that are a couple of years older or so I tend to find that they've spent some time abusing Fortran code in some fashion.  Fortran isn't a language that I've ever learned, but it's probably one of those languages that a lot of engineers have dabbled with at some point.

One trend I've noticed in a lot of younger engineers is a reluctance to create computer code and indeed even in creating what I would consider simple spreadsheets to make a calculation tool that can run several scenarios for them and validate an approach to determine the boundaries of their calculations.  Increasingly there seems to be a preponderancy for young engineers to select their FEM weapon of choice and throw triangles at it until the model begs for mercy, or to download an app that some other bright spark has written to do at least part of the process of what they want to happen.  None of this promotes a deeper understanding of how the process works though unfortunately.

101:365 - Studious...

Perhaps the days of writing your own code are long gone for young engineers? But part of me thinks that they are missing out on a real opportunity to structure their understanding of the steps needed to do certain tasks as they assemble their code.  Writing code to perform a task, whether on a spreadsheet or in a more formal programming language, is a great way to develop understanding and to explore the intricacies of design codes and I feel that younger engineers are missing out on this experience by only using off the shelf packages.

One encouraging aspect is that with the launch of the Raspberry Pi I can see that if this continues to gather momentum that younger generations will again an ability to tinker and break programming code and gain an appreciation of the advantages that breaking down engineering problems into a series of procedural steps can bring.

At least for the next year or so I'm still responsible for sculpting young engineers minds and I'm determined to develop a fun way of getting them to extend their understanding of how to write code or spreadsheets, I just need to work out a way of doing this within the confines of the resources I do or don't have available.

What do you think? Should engineers know how to programme or at least be able to create simple spreadsheets?