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

📄 local.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 "Local.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) */    Pfloat	KnotVals[13];		/* array for knot vectors */    Pfloat_list	Knots;			/* list of floats */    Pint	NumKnots, NumSegs;	/* number of knots, segments */    static Ppoint3 CtrlPts[10] = {	{0.1, 0.1, 0.0}, {0.1, 0.5, 0.0}, {0.3, 0.8, 0.0}, {0.2, 0.9, 0.0},	{0.5, 0.9, 0.0}, {0.3, 0.2, 0.0}, {0.6, 0.0, 0.0}, {0.7, 0.2, 0.0},	{0.7, 0.7, 0.0}, {0.9, 0.9, 0.0}};    Pctrl_point3_list	CtrlPtList;	/* list of control points */    static Ppoint_list3 MarkerList =	/* for polymarkers */	{10, CtrlPts};    Pcurve_geom_spline	Curve;		/* the spline definition */    int		I;			/* loop control variable */    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);    Curve.order = 3;    pset_marker_type(PMARKER_ASTERISK);    pset_marker_size(4.0);    MakeKnotVector(Curve.order, 10, &KnotVals, &NumKnots, &NumSegs);    Knots.num_floats = NumKnots;    Knots.floats = KnotVals;    Curve.knots = Knots;    Curve.low_limit = 0.0;    Curve.high_limit = (float) NumSegs;    CtrlPtList.rationality = PB_SPLINE_NON_RATIONAL;    CtrlPtList.num_points = 10;    CtrlPtList.points.point3 = CtrlPts;    Curve.ctrl_points = CtrlPtList;    for (I = 1; I <= 5; I++) {	CtrlPts[6].y = I * 0.1;		/* change one control point */	ppolymarker3(&MarkerList);	pnon_uniform_b_spline_curve3(&Curve);    }    pclose_struct();    ppost_struct(WorkstnID, TheStructure, 1.0);    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 + -