Projections::PERSP, [real factor = 1, [const unsigned short sort_value = Sorting::MAX_Z, [const bool do_warnings = true, [const real min_x_proj = -40, [const real max_x_proj = 40, [const real min_y_proj = -40, [const real max_y_proj = 40, [const real min_z_proj = -40, [const real max_z_proj = 40]]]]]]]]]])Projections::PERSP, [real factor = 1, [const unsigned short sort_value = Sorting::MAX_Z, [const bool do_warnings = true, [const real min_x_proj = -40, [const real max_x_proj = 40, [const real min_y_proj = -40, [const real max_y_proj = 40, [const real min_z_proj = -40, [const real max_z_proj = 40]]]]]]]]]])These functions create a two-dimensional projection of the objects on the
Pictureand write MetaPost code toout_streamfor drawing it.The arguments:
const Focus&f- The
Focusused for projection, also known as the center of projection, or the camera. This argument is used in the first version only. The second version, without aconst Focus&f argument, merely calls the first version and passes it the global variabledefault_focusas its first argument, sodefault_focusis effectively the default for f. Defining two versions in this way makes it possible to calloutput()withprojectionas its first (and possibly only) argument. If instead, f were an optional argument withdefault_focusas its default, this wouldn't have been possible. It also wouldn't be possible to have f have a default in the first version, and to retain the second version, because the compiler wouldn't be able to resolve a call tooutput()with no arguments.const unsigned shortprojection- Default:
Projections::PERSP. The type of projection. Valid values areconst unsigned shortsdefined innamespace Projections(see Namespace Projections):
PERSPfor the perspective projection,
PARALLEL_X_Yfor parallel projection onto the x-y plane,
PARALLEL_X_Zfor parallel projection onto the x-z plane, and
PARALLEL_Z_Yfor parallel projection onto the z-y plane. %% !! TO DO: I plan to add isometric and axionometric projections soon.realfactor- Default: 1. Passed from
output()toextract()and from there toproject(). Theworld_coordinatesof thePointsthat are projected are multiplied by factor, which enlarges or shrinks the projected image without altering thePictureitself. factor is probably most useful for parallel projections, where theFocusf isn't used; with a perspective projection, the parameters of theFocuscan be used to influence the size of the projected image.const unsigned shortsort_value- Default:
Sorting::MAX_Z. The value used should be one of the constants defined innamespace Sorting, See Namespace Sorting, above. IfMAX_Z(the default) is used, theShapeson thePictureare sorted according to the maximum z-value of theprojective_extremesof thePointsbelonging to theShape. IfMIN_Zis used, they are sorted according to the minimum z-value, and ifMEAN_Zis used, they are sorted according to the mean of the maximum and minimum z-values. IfNO_SORTis used, theShapesare output in the order in which they were put onto thePicture.The surface hiding algorithm implemented in 3DLDF is quite primitive, and doesn't always work right. For
Shapesthat intersect, it can't work right. I plan to work on improving the surface hiding algorithm soon. This is not a trivial problem. To solve it properly, eachShapeon aPicturemust be tested for intersection with every otherShapeon thePicture. If two or moreShapesintersect, they must be broken up into smaller objects until there are no more intersections. I don't expect to have a proper solution soon, but I expect that I will be able to make some improvements. See Surface Hiding.const booldo_warnings- Default:
true. Iftrue,output()issues warnings tostderr(standard error output) if aShapecannot be output because it lies outside the limits set by the following arguments. Sometimes, a user may only want to project a portion of aPicture, in which case such warnings would not be helpful. In this case, do_warnings should befalse.const realmin_x_proj- Default: -40. The minimum x-coordinate of the projection of a
Shapesuch that theShapecan be output. Ifprojective_coordinates[0]of anyPointon aShapeis less than min_x_proj, theShapewill not be projected at all.const realmax_x_proj- Default: 40. The maximum x-coordinate of the projection of a
Shapesuch that theShapecan be output. Ifprojective_coordinates[0]of anyPointon aShapeis greater than max_x_proj, theShapewill not be projected at all.const realmin_y_proj- Default: -40. The minimum y-coordinate of the projection of a
Shapesuch that theShapecan be output. Ifprojective_coordinates[1]of anyPointon aShapeis less than min_y_proj, theShapewill not be projected at all.const realmax_y_proj- Default: 40. The maximum y-coordinate of the projection of a
Shapesuch that theShapecan be output. Ifprojective_coordinates[1]of anyPointon aShapeis greater than max_y_proj, theShapewill not be projected at all.const realmin_z_proj- Default: -40. The minimum z-coordinate of the projection of a
Shapesuch that theShapecan be output. Ifprojective_coordinates[2]of anyPointon aShapeis less than min_z_proj, theShapewill not be projected at all.const realmax_z_proj- Default: 40. The maximum z-coordinate of the projection of a
Shapesuch that theShapecan be output. Ifprojective_coordinates[2]of anyPointon aShapeis greater than max_z_proj, theShapewill not be projected at all.
Suppresses output of the
Labelson aPicturewhenoutput()is called. This can be useful when aPictureis output, transformed, and output again, one or more times, in a single figure. Usually, it will not be desirable to have theLabelsoutput more than once.In [next figure] ,
current_pictureis output three times, but theLabelson it are only output once.Ellipse e(origin, 3, 5); e.label(); e.draw(); Point pt0(-3); Point pt1(3); pt0.draw(pt1); Point pt2(0, 0, -4); Point pt3(0, 0, 4); pt2.draw(pt3); pt0.dotlabel("0", "lft"); pt1.dotlabel("1", "rt"); pt2.dotlabel("2", "bot"); pt3.dotlabel("3"); current_picture.output(Projections::PARALLEL_X_Z); current_picture.rotate(0, 60); current_picture.suppress_labels(); current_picture.output(Projections::PARALLEL_X_Z); current_picture.rotate(0, 60); current_picture.output(Projections::PARALLEL_X_Z);
![]()
Fig. 79.