MATLAB 3D Plot Using Balls and Sticks

**BALL_AND_STICK_DISPLAY**
is a MATLAB program which
illustrates the use of MATLAB's 3D plotting capability to make
a "ball and stick" plot.

MATLAB has many procedures for displaying numeric data in 3D using contours, vector plots, surfaces and so on. However, sometimes an illustrator needs to construct a simple 3D image of points and lines. Since the thing has to show up as an illustration or a slide, the points are exaggerated to balls, and the lines to sticks.

MATLAB's **plot3** command can create both kinds of objects, but
it helps to know how to specify the desired object properties for
color and size. The MATLAB help system is not very helpful when trying
to find out what properties you can specify and what values they can have.

So this program may be a helpful example of how a 3D object can be created with knobby balls and colored sticks.

The particular object created here is intended to illustrate the Lax-Wendroff scheme for approximating the solution of a hyperbolic partial differential equation. The blue spheres represent points at which data is known. The green spheres represent points at which fluxes are estimated by computing differences between neighboring values. The red sphere is the locationi of the updated solution value.

The computer code and data files made available on this web page are distributed under the GNU LGPL license.

**BALL_AND_STICK_DISPLAY** is available in
a MATLAB version.

BEZIER_SURFACE_DISPLAY, a MATLAB program which displays a Bezier surface;

CIRCLE_GRID_DISPLAY, a MATLAB program which reads a matrix of integers, and draws a corresponding grid of circles filled with color.

GRID_DISPLAY, a MATLAB library which can display a 2D or 3D grid or sparse grid.

OBJ_DISPLAY, a MATLAB program which reads an OBJ 3D graphics file and displays it on the screen.

PLY_DISPLAY, a MATLAB program which displays an image of a 3D graphics file in PLY format;

POLYGONAL_SURFACE_DISPLAY, a MATLAB program which displays a surface in 3D described as a set of polygons;

QUAD_SURFACE_DISPLAY, a MATLAB program which plots piecewise bilinear data associated with a QUAD_SURFACE, that is, a 3D surface defined by a quadrilateral mesh;

STLA_DISPLAY, a MATLAB program which reads an ASCII STL file and displays it on the screen.

TET_MESH_DISPLAY, a MATLAB program which reads in the node and tetra files defining a tet mesh and displays a wireframe image.

TRI_SURFACE_DISPLAY, a MATLAB program which displays the 3D graphics information in a TRI_SURFACE file;

XYZ_DISPLAY, a MATLAB program which reads XYZ information defining points in 3D, and displays an image in the MATLAB graphics window.

XYZF_DISPLAY, a MATLAB program which reads XYZF information defining points and faces in 3D, and displays an image using OpenGL.

XYZL_DISPLAY, a MATLAB program which reads XYZL information defining points and lines in 3D, and displays an image in a MATLAB graphics window.

**BALL_AND_STICK_DISPLAY** displays a ball and stick plot.

- ball_and_stick_display.m, the source code.
- ball_and_stick_display.png, a PNG snapshot of the 3D plot.

**FIRST_ORDER_DISPLAY** displays a sequence of 8 images
illustrating a first order method for dealing with hyperbolic
equations. Hitting RETURN proceeds
to the next image.

- first_order_display.m, the source code.
- first_order_0.png, a blank plotting field.
- first_order_1.png, a node where we have the solution.
- first_order_2.png, the region associated with the node.
- first_order_3.png, the neighboring nodes.
- first_order_4.png, fluxes are differences across the neighbors.
- first_order_5.png, a full time step is now taken.
- first_order_6.png, we have an estimate for the solution in this region.
- first_order_7.png, all the nodes can be advanced in this way.

**LAX_WENDROFF_1D_DISPLAY** displays a sequence of images
illustrating the Lax-Wendroff method in 1D. Hitting RETURN proceeds
to the next image.

- lax_wendroff_1d_display.m, the source code.
- lw1d00.png, a blank plotting field.
- lw1d01.png, a node where we have the solution.
- lw1d02.png, the region associated with the node.
- lw1d03.png, the neighboring nodes.
- lw1d04.png, values at midsides by averaging.
- lw1d05.png, values at midside nodes, half time step.
- lw1d06.png, estimate fluxes.
- lw1d07.png, estimate derivative at node, half time step.
- lw1d08.png, take full step to new time.
- lw1d09.png, update all data.
- lw1d10.png, ready for next time step.

**LAX_WENDROFF_2D_DISPLAY** displays a sequence of images
illustrating the Lax-Wendroff method in 2D. Hitting RETURN proceeds
to the next image.

- lax_wendroff_2d_display.m, the source code.
- lw2d0.png, a blank plotting field.
- lw2d1.png, a node where we have the solution.
- lw2d2.png, the region associated with the node.
- lw2d3.png, the neighboring nodes.
- lw2d4.png, values at midsides by averaging.
- lw2d5.png, values at midside nodes, half time step.
- lw2d6.png, estimate fluxes.
- lw2d7.png, estimate derivative at node, half time step.
- lw2d8.png, take full step to new time.
- lw2d9.png, update all data.

You can go up one level to the MATLAB source codes.