Thursday, March 6, 2014
Mathcad 3D Graphics - Ball & Stick Glitchs
It's a little surprising that the ball and stick surface plots actually work as well as they do. The 3D plotter doesn't appear to be designed to handle complex data sets. Nor is its matrix handling capabilities quite up to the task. Mathcad 11 does have a limited capability for handling nested matrices (those whose elements are also matrices). So I was able to simplify the process for creating a ball and stick model but had to write a few Mathcad programs to compute the spheres and cylinders and stack them. It would be better to use an indexed set of objects to be plotted but the plotter wasn't designed to handle them. Using the stacked matrices produces lines linking the objects if one tries to draw the grids on their surfaces. But one normally would not be interested in that much detail.
For the tetrahedral model one needs to know the positions of the vertices and some parameters to specify the dimensions of the balls and sticks.
The coordinates of the points were initially chosen for convenience and then translated so that the origin was at their mean. Next the set of balls, B, was found using the balls function and the set of sticks, S, using the sticks function. Both B and S contain nested sets of arrays of points and had to be converted into stacked matrices for the plotter. We see from the following data that B is a nested vector with four rows and S has 6 rows. They contain the 4 balls and 6 sticks. Each sphere in B has 20 lines of "latitude" and 30 lines of "longitude" while for the cylinders there are 20 and 10 respectively with two extra lines of longitude for the center points of the spheres and end points of the cylinders. For each point of latitude and longitude there is a 3 dimensional point.
The plotter just needs the two sets of three coordinates to plot the surfaces.
In this case all six links were needed for the model but in general one would probably have to use a table to specify which lines are to be plotted. For chemistry ball and stick models of atoms one would have to plot each set of atoms separately giving them different colors.