Previous section-----Next section

3.4.1 Graphics Functions

The Modeler2D graphics functions closely parallel the built-in Mathematica graphics primitives. Each graphics function generates Mathematica graphics primitives that represent points, lines, or polygons.

Basic Mech graphics function.

More 2D graphics functions.

Options for graphics functions.

The Modeler2D Vertex, Edge, and Facet functions are analogous to the built-in Mathematica Point, Line, and Polygon functions. To demonstrate these functions, graphics objects are generated that are located on body 2, which is named body2.

This loads the Modeler2D package.

Here is a box with a diagonal and a couple of points.

The coordinates of the graphic just created bdgraph are functions of the Modeler2D variables that locate body2: X2, Y2, and CapitalTheta2. Therefore, these variables must be replaced with numeric values before the graphic can be displayed with Show.

This shows bdgraph rotated 0.5 radians counterclockwise.

This shows bdgraph rotated 1 radian and translated 1 unit to the right.

The Box function is analogous to the built-in Rectangle function, with the exception that the sides of the Box graphic are aligned with the local coordinate system in which the graphic is located, instead of being aligned with the global coordinate system.
The Bar function also generates a rectangular box, but instead of specifying two points on two opposite corners, two points on two opposing sides of the rectangle are specified. The Faces option is used with the Bar function to show only an outline of the bar. Unlike the Box function, Bar accepts an axis object as its first argument, to allow the two endpoints of the bar to lie on two different bodies.

Here is a Box graphic on body2 and a Bar graphic spanning from body2 to the ground, with an Edge graphic down the middle.

Here is the result.

The Wheel function is used here to generate an octagon with a hole in it. Note that the n-gon returned by Wheel is placed on the body that is referenced in the Point argument, and is located with that body as such.

This generates an octagon on body2.

Here is the result.