⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orders.c

📁 Intro/: Directory containing introductory examples. HelloWorld.c A simple program that draws a bo
💻 C
字号:
#include <phigs.h>			/* get HP-PHIGS definitions for C */#include <stdio.h>			/* get standard I/O definitions */#include <math.h>			/* link with library "-lm" */main()					/* file "Orders.c" */{    Pint	WorkstnID = 1;		/* workstation identifier */    Pint	ConnID;			/* connection identifier */    Pint	WorkstnType = POIDDX;	/* out/in, direct, dbl bfr, Xwindow */    Pint	TheStructure = 1;	/* structure ID (chosen by user) */    static Plimit Window = {0.0, 1.0, 0.0, 1.0};/* \  to define	the */    Plimit	Viewport;			/*  > view mapping  */    Pview_map	ViewMapping;			/* /  matrix	    */    Pmatrix	ViewMapMat;			/* \		      */    static Pmatrix ViewOriMat = {1.0, 0.0, 0.0,	/*  \  to define      */				 0.0, 1.0, 0.0,	/*   > the view	      */				 0.0, 0.0, 1.0};/*  /  representation */    Pview_rep	ViewRep;			/* /		      */    Pint	Linear = 2, Quadratic = 3, Cubic = 4, Quartic = 5, Quintic = 6;    char	OrderNames[][18] = {	/* names of the splines' orders */	"Linear/Quadratic", "Linear/Cubic", "Linear/Quartic",	"Linear/Quintic"};    Pfloat	KnotVals[13];		/* array for knot vectors */    Pfloat_list	Knots;			/* list of floats */    Pint	NumKnots, NumSegs;	/* number of knots, segments */    static Ppoint3	CtrlPts[7] = {{0.1, 0.3, 0.0},	    /* \  define  */	{0.3, 0.9, 0.0},  {0.4, 0.4, 0.0}, {0.5, 0.6, 0.0}, /*  \ the	  */	{0.6, 0.15, 0.0}, {0.8, 0.2, 0.0}, {0.9, 0.6, 0.0}};/*  / control */    static Pctrl_point3_list CtrlPtList =		    /* /  points  */	 {PB_SPLINE_NON_RATIONAL, 7, CtrlPts};    Pcurve_geom_spline	Curve;		/* the spline definition */    static Ptext_align Alignment = {PHOR_CTR, PVERT_BOTTOM};    Ppoint 	Loc;			/* position of text string */    Pint	Error;			/* error-return variable */    Pint	Quadrant, I, J;		/* loop control variables */    popen_phigs((char *) stderr, 0);	/* errors go to "stderr" */    pescape_u4("/dev/screen/phigs_window", &ConnID);    popen_ws(WorkstnID, (void *) ConnID, WorkstnType);    popen_struct(TheStructure);    pset_char_ht(0.07);    pset_char_expan(0.7);    pset_text_align(&Alignment);    Curve.ctrl_points = CtrlPtList;    for (Quadrant = 0; Quadrant < 4; Quadrant++) {	/*--- define the viewing ------------------  four images: +---+---+ */	Viewport.x_min = (Quadrant % 2) *  0.5;		       /* | 1 | 2 | */	Viewport.x_max = Viewport.x_min + 0.5;		       /* +---+---+ */	Viewport.y_min = (Quadrant < 2) * 0.5;		       /* | 3 | 4 | */	Viewport.y_max = Viewport.y_min + 0.5;		       /* +---+---+ */	ViewMapping.win = Window;	ViewMapping.proj_vp = Viewport;	peval_view_map_matrix(&ViewMapping, &Error, ViewMapMat);	for (I = 0; I < 3; I++)	    for (J = 0; J < 3; J++)		ViewRep.ori_matrix[I][J] = ViewOriMat[I][J],		ViewRep.map_matrix[I][J] = ViewMapMat[I][J];	ViewRep.clip_limit = Window;	ViewRep.xy_clip    = PIND_CLIP;	pset_view_rep(WorkstnID, Quadrant + 1, &ViewRep);	pset_view_ind(Quadrant + 1);	/*--- define the reference curve (linear) --------------------------*/	Curve.order = Linear;	MakeKnotVector(Curve.order, 7, KnotVals, &NumKnots, &NumSegs);	Knots.num_floats = NumKnots;	Knots.floats = KnotVals;	Curve.knots = Knots;	Curve.low_limit = 0.0;	Curve.high_limit = (float) NumSegs;	pnon_uniform_b_spline_curve3(&Curve);	/*--- define the higher-order curve --------------------------------*/	Curve.order = Linear + Quadrant + 1;	MakeKnotVector(Curve.order, 7, KnotVals, &NumKnots, &NumSegs);	Knots.num_floats = NumKnots;	Knots.floats = KnotVals;	Curve.knots = Knots;	Curve.low_limit = 0.0;	Curve.high_limit = (float) NumSegs;	pnon_uniform_b_spline_curve3(&Curve);	/* higher-order curve */	Loc.x = 0.5, Loc.y = 0.03;	ptext(&Loc, OrderNames[Quadrant]);    }    pclose_struct();    ppost_struct(WorkstnID, TheStructure, 1.0);    pupd_ws(WorkstnID, PFLAG_PERFORM);    pclose_ws(WorkstnID);    pclose_phigs();}/****************************************************************************/MakeKnotVector(Order, NumCtrlPts, KnotVector, NumKnots, NumSegs)Pint	Order;			/* order of the spline */Pint	NumCtrlPts;		/* number of control points in the curve */Pfloat	*KnotVector;		/* the returned knot vector */Pint	*NumKnots;		/* number of knots in vector */Pint	*NumSegs;		/* number of segments in curve */{        int	I;			/* loop control variable */    int	Knot;			/* array index */        *NumSegs = NumCtrlPts + 1 - Order;	/* calculate number of segments */    *NumKnots = Order + NumCtrlPts;	/* calculate number of knots */    Knot = 0;				/* initialize the index */    /*--- define the multiples at the beginning of the knot vector ---------*/    for (I = 1; I <= Order; I++)	KnotVector[Knot++] = 0.0;		/* define the element */    /*--- define the middle chunk ------------------------------------------*/    for (I = 1; I <= *NumSegs; I++)	KnotVector[Knot++] = (float) I;		/* define the element */    /*---- define the multiples at the end of the knot vector ---------------*/    for (I = 1; I <= Order; I++)	KnotVector[Knot++] = (float) *NumSegs;	/* define the element */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -