Previous Next Up Title Contents Index Functions Index Top Library

1.7.6. DRAWING A PARALLELEPIPED

/* include file containing the "define" and types specific to PHIGURE */
#include <phigure.h>

main () {
	Pfloat zoom=1.0;
	Pint ws_id = 1, view_ind = 1,
	scene_id = 10, cube_id = 11, system_id=12;

	static Plimit3 viewport = {0.,1., 0., 1., 0.,1.}, domain = {10., 20., 10., 30., 5.,35.};
	static Ppoint3 first_corner={10.,10.,5.},second_corner={20.,30.,35.},
	domain_center={15.,20.,20.},view_center={0.5,0.5,0.5};

	static Pint struct_ids[2];
	static Pint_list struct_id_list = {2, struct_ids};

/* open PHIGURE and an X-Window type workstation (8887) */
	topen_phigure (PDEF_ERR_FILE);
	topen_ws (ws_id, PDEF_ERR_FILE, 8887);

/* define domain */
	tdomain3 (&domain);

/* build parallelepiped */
	tcube (cube_id, &first_corner, &second_corner);

/* build system with a type of dotted line */
	tcoordinate_system_axis (system_id,&domain_center,&second_corner,"X","Y","Z", 0.1,0.1);
	tset_linetype (system_id, -1, PLINE_DASH);

/* define scene */
	struct_ids[0] = cube_id;
	struct_ids[1] = system_id;
	tscene (scene_id, &struct_id_list, view_ind);

/* define 3D view perspective*/
	tview3_perspect_z_vert (ws_id, view_ind, &view_center, 55., 25., 3.0, zoom, &viewport);

/* display scene on workstation */
	ppost_struct (ws_id, scene_id, 1.0);
	predraw_all_structs (ws_id, PFLAG_ALWAYS);

/* close workstation and PHIGURE */
	tclose_ws (ws_id);
	tclose_phigure ();
}

This program displays a parallelepiped and a marker in 3D. The view is defined in perspective showing the Z axis vertical. As the domain has been defined as the limits of the parallelepiped, scene transformation changes it into a cube.


Previous Next Up Title Contents Index Functions Index Top Library