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

📄 output.cc

📁 模糊聚类的算法实现程序
💻 CC
📖 第 1 页 / 共 5 页
字号:
		    inputData->Lese_Vektor (counter, yindex),		    &tempx, &tempy);    distance = ((inputData->Lese_Vektor (counter, xindex) - xoutput) * (inputData->Lese_Vektor (counter, xindex) - xoutput)) +      ((inputData->Lese_Vektor (counter, yindex) - youtput) * (inputData->Lese_Vektor (counter, yindex) - youtput));    if (distance < mindistance) {      mindistance = distance;      nearestcounter = counter;    }  }  *index = nearestcounter;  WorldtoPixel2d (inputData->Lese_Vektor (nearestcounter, xindex),		  inputData->Lese_Vektor (nearestcounter, yindex),		  xis, yis);  return &(inputData->Lese_Vektor (nearestcounter));}DVektor *Output2d_3d::Getnearestpoint3d (short xpos, short ypos, int *index, short *xis, short *yis){  DVektorArray *inputData = &(Dataset->Lese_Daten ());  short tempx, tempy;  int counter, nearestcounter = 0;  double distance, mindistance = MAXDOUBLE;	// distance * distance  for (counter = 0; counter < inputData->Lese_Groesse (); counter++) {    WorldtoPixel3d (inputData->Lese_Vektor (counter, xindex),		    inputData->Lese_Vektor (counter, yindex),		    inputData->Lese_Vektor (counter, zindex),		    &tempx, &tempy);    distance = ((xpos - tempx) * (xpos - tempx)) +      ((ypos - tempy) * (ypos - tempy));    if (distance < mindistance) {      *xis = tempx;      *yis = tempy;      mindistance = distance;      nearestcounter = counter;    }  }  *index = nearestcounter;  return &(inputData->Lese_Vektor (nearestcounter));}void Output2d_3d::DrawPoint (short xpos, short ypos, int options, int number, short pointtyp){  Drawable drawable;  if (options & DRAWINWINDOW)    drawable = window;  else    drawable = pixmap;  if (options & DRAWMARKED)    XSetForeground (display, gc, redpix);  else    XSetForeground (display, gc, blackpix);  if (options & DRAWTEMP)    XSetFunction (display, gc, GXxor);  switch (pointtyp) {  case OUTPUT_POINTTYPPOINT:    if (options & DRAWMARKED) {      XSegment lines[2];      lines[0].y1 = lines[0].y2 = ypos;      lines[0].x1 = xpos - CROSSWIDTH;      lines[0].x2 = xpos + CROSSWIDTH;      lines[1].x1 = lines[1].x2 = xpos;      lines[1].y1 = ypos - CROSSWIDTH;      lines[1].y2 = ypos + CROSSWIDTH;      XDrawSegments (display, drawable, gc, lines, 2);    } else      XDrawPoint (display, drawable, gc, xpos, ypos);    break;			// case OUTPUT_POINTTYPPOINT  case OUTPUT_POINTTYPCROSS:    XSegment lines[2];    if (options & DRAWMARKED) {      lines[0].y1 = lines[0].y2 = ypos;      lines[0].x1 = xpos - 2 * CROSSWIDTH;      lines[0].x2 = xpos + 2 * CROSSWIDTH;      lines[1].x1 = lines[1].x2 = xpos;      lines[1].y1 = ypos - 2 * CROSSWIDTH;      lines[1].y2 = ypos + 2 * CROSSWIDTH;    } else {      lines[0].y1 = lines[0].y2 = ypos;      lines[0].x1 = xpos - CROSSWIDTH;      lines[0].x2 = xpos + CROSSWIDTH;      lines[1].x1 = lines[1].x2 = xpos;      lines[1].y1 = ypos - CROSSWIDTH;      lines[1].y2 = ypos + CROSSWIDTH;    }    XDrawSegments (display, drawable, gc, lines, 2);    break;			// case OUTPUT_POINTTYPCROSS  case OUTPUT_POINTTYPCLASSES:    DrawSymbol (xpos, ypos,		drawable, number);    break;  case OUTPUT_POINTTYPCOLOR:    DrawBox (xpos, ypos, drawable);    break;  }  XSetFunction (display, gc, GXcopy);}void Output2d_3d::DrawPoint2d (DVektor * me, int options, short pointtyp){  if (Dataset->Lese_Daten ().Lese_Dim () > 1) {    short tempx, tempy;    WorldtoPixel2d (me->Lese_i (xindex), me->Lese_i (yindex),		    &tempx, &tempy);    DrawPoint (tempx, tempy, options, me->Lese_Nummer (), pointtyp);  } else {    short xpixel, ypixel;    WorldtoPixel1d (Getvektorindex (me, &(Dataset->Lese_Daten ())),		    me->Lese_i (xindex),		    &xpixel, &ypixel);    DrawPoint (xpixel, ypixel, options, me->Lese_Nummer (), pointtyp);  }}void Output2d_3d::DrawPoint3d (DVektor * me, int options, short pointtyp){  short xpixel, ypixel;  WorldtoPixel3d (me->Lese_i (xindex),		  me->Lese_i (yindex),		  me->Lese_i (zindex),		  &xpixel, &ypixel);  DrawPoint (xpixel, ypixel,	     options,	     me->Lese_Nummer (),	     pointtyp);}void Output2d_3d::DrawAxes2d (char options, char *text1, char *text2){  short axis[3][2];  double xscalebackup = xscale, yscalebackup = yscale;  xscale = yscale = 1.0;  double arrowwidth, arrowlength;  short textoffset, textheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;  arrowwidth = ARROWWIDTHMULT;  arrowlength = ARROWLENGTHMULT;  XPoint arrow1[3], arrow2[3];  Drawable drawable;  if (options & DRAWINWINDOW)    drawable = window;  else    drawable = pixmap;  XSetForeground (display, gc, blackpix);//       arrow2[]  //        / \ axis[2][.]  //         |  //         |  //         |  //         |  //         ----------> axis[1][.]  //    axis[0][.]   arrow1[]  WorldtoPixel2d (0.0, 0.0, &(axis[0][0]), &(axis[0][1]));  WorldtoPixel2d (1.0, 0.0, &(axis[1][0]), &(axis[1][1]));  WorldtoPixel2d (0.0, 1.0, &(axis[2][0]), &(axis[2][1]));  WorldtoPixel2d (1.0, 0, &(arrow1[0].x), &(arrow1[0].y));  WorldtoPixel2d (1.0 - arrowlength, arrowwidth, &(arrow1[1].x), &(arrow1[1].y));  WorldtoPixel2d (1.0 - arrowlength, -arrowwidth, &(arrow1[2].x), &(arrow1[2].y));  WorldtoPixel2d (0, 1.0, &(arrow2[0].x), &(arrow2[0].y));  WorldtoPixel2d (arrowwidth, 1.0 - arrowlength, &(arrow2[1].x), &(arrow2[1].y));  WorldtoPixel2d (-arrowwidth, 1.0 - arrowlength, &(arrow2[2].x), &(arrow2[2].y));  XSegment lines[] =  {    {axis[0][0], axis[0][1], axis[1][0], axis[1][1]},    {axis[0][0], axis[0][1], axis[2][0], axis[2][1]}  };  if (text1 != 0) {    textoffset = XTextWidth (fontstruct, text1, strlen (text1)) / 2;    XDrawString (display, drawable, gc,		 axis[1][0] - textoffset, axis[1][1] + textheight,		 text1, strlen (text1));  }  if (text2 != 0) {    textoffset = XTextWidth (fontstruct, text2, strlen (text2)) / 2;    XDrawString (display, drawable, gc,		 axis[2][0] - textoffset, axis[2][1],		 text2, strlen (text2));  }  XDrawSegments (display, drawable, gc, lines, 2);  XFillPolygon (display, drawable, gc, arrow1, 3, Convex, CoordModeOrigin);  XFillPolygon (display, drawable, gc, arrow2, 3, Convex, CoordModeOrigin);  xscale = xscalebackup;  yscale = yscalebackup;}void Output2d_3d::DrawAxes3d (char options, char *text1, char *text2, char *text3){  int axis[7][2];  double x, y, z;  XPoint points[3];  XPoint points2[4];  double arrowwidth, arrowlength;  short textoffset;// select arrowlength from shortesr axis:  arrowwidth = ARROWWIDTHMULT;  arrowlength = ARROWLENGTHMULT;  Drawable drawable;  if (options & DRAWINWINDOW)    drawable = window;  else    drawable = pixmap;  XSetForeground (display, gc, blackpix);// (0,0,0)  // transformation: axescoordinates -> worldcoordinates  x = axisframe[0][3];  y = axisframe[1][3];  z = axisframe[2][3];// projection: 3d -> 2d  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);// 2d -> pixelvalues  axis[0][0] = xcenter + (int) (x * scalefactor);  axis[0][1] = ycenter - (int) (y * scalefactor);// (1.0,0,0)  x = axisframe[0][0] + axisframe[0][3];  y = axisframe[1][0] + axisframe[1][3];  z = axisframe[2][0] + axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  axis[1][0] = xcenter + (int) (x * scalefactor);  axis[1][1] = ycenter - (int) (y * scalefactor);  if (text1 != 0) {    textoffset = XTextWidth (fontstruct, text1, strlen (text1)) / 2;    XDrawString (display, drawable, gc, axis[1][0] - textoffset, axis[1][1], text1, strlen (text1));  }// (0,1.0,0)  x = axisframe[0][1] + axisframe[0][3];  y = axisframe[1][1] + axisframe[1][3];  z = axisframe[2][1] + axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  axis[2][0] = xcenter + (int) (x * scalefactor);  axis[2][1] = ycenter - (int) (y * scalefactor);  if (text2 != 0) {    textoffset = XTextWidth (fontstruct, text2, strlen (text2)) / 2;    XDrawString (display, drawable, gc, axis[2][0] - textoffset, axis[2][1], text2, strlen (text2));  }// (0,0,1.0)  x = axisframe[0][2] + axisframe[0][3];  y = axisframe[1][2] + axisframe[1][3];  z = axisframe[2][2] + axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  axis[3][0] = xcenter + (int) (x * scalefactor);  axis[3][1] = ycenter - (int) (y * scalefactor);  if (text3 != 0) {    textoffset = XTextWidth (fontstruct, text3, strlen (text3)) / 2;    XDrawString (display, drawable, gc, axis[3][0] - textoffset, axis[3][1], text3, strlen (text3));  }  XSegment linesright[] =  {    {axis[0][0], axis[0][1], axis[1][0], axis[1][1]},    {axis[0][0], axis[0][1], axis[2][0], axis[2][1]},    {axis[0][0], axis[0][1], axis[3][0], axis[3][1]}  };  XDrawSegments (display, drawable, gc, linesright, 3);// next draw arrows on end of axes  double localx, localy, localz;// first arrows on X-axis  //local point (1.0, 0, 0)  points[0].x = axis[1][0];  points[0].y = axis[1][1];//local point (1.0-ARROWLENGTHMULT,  //             ARROWWIDTHMULT,  //             0)  localx = 1.0 - arrowlength;  localy = arrowwidth;  x = axisframe[0][0] * localx +    axisframe[0][1] * localy +    axisframe[0][3];  y = axisframe[1][0] * localx +    axisframe[1][1] * localy +    axisframe[1][3];  z = axisframe[2][0] * localx +    axisframe[2][1] * localy +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[0].x = points[1].x = xcenter + (int) (x * scalefactor);  points2[0].y = points[1].y = ycenter - (int) (y * scalefactor);//local point (1-ARROWLENGTHMULT,  //             -ARROWWIDTHMULT,  //             0)  x = axisframe[0][0] * localx -    axisframe[0][1] * localy +    axisframe[0][3];  y = axisframe[1][0] * localx -    axisframe[1][1] * localy +    axisframe[1][3];  z = axisframe[2][0] * localx -    axisframe[2][1] * localy +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[2].x = points[2].x = xcenter + (int) (x * scalefactor);  points2[2].y = points[2].y = ycenter - (int) (y * scalefactor);  XFillPolygon (display, drawable, gc, points, 3, Convex, CoordModeOrigin);// local point (1-ARROWLENGTHMULT,  //              0,  //              ARROWWIDTHMULT)  localx = 1.0 - arrowlength;  localz = arrowwidth;  x = axisframe[0][0] * localx +    axisframe[0][2] * localz +    axisframe[0][3];  y = axisframe[1][0] * localx +    axisframe[1][2] * localz +    axisframe[1][3];  z = axisframe[2][0] * localx +    axisframe[2][2] * localz +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[1].x = points[1].x = xcenter + (int) (x * scalefactor);  points2[1].y = points[1].y = ycenter - (int) (y * scalefactor);// local point (1-ARROWLENGTHMULT,  //              0,  //              -ARROWWIDTHMULT)  x = axisframe[0][0] * localx -    axisframe[0][2] * localz +    axisframe[0][3];  y = axisframe[1][0] * localx -    axisframe[1][2] * localz +    axisframe[1][3];  z = axisframe[2][0] * localx -    axisframe[2][2] * localz +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[3].x = points[2].x = xcenter + (int) (x * scalefactor);  points2[3].y = points[2].y = ycenter - (int) (y * scalefactor);  XFillPolygon (display, drawable, gc, points, 3, Convex, CoordModeOrigin);  XFillPolygon (display, drawable, gc, points2, 4, Convex, CoordModeOrigin);// second arrows on Y-axis  //local point (0, 1.0, 0)  points[0].x = axis[2][0];  points[0].y = axis[2][1];//local point (0,  //             1-ARROWLENGTHMULT,  //             ARROWWIDTHMULT)  localy = 1.0 - arrowlength;  localz = arrowwidth;  x = axisframe[0][1] * localy +    axisframe[0][2] * localz +    axisframe[0][3];  y = axisframe[1][1] * localy +    axisframe[1][2] * localz +    axisframe[1][3];  z = axisframe[2][1] * localy +    axisframe[2][2] * localz +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[0].x = points[1].x = xcenter + (int) (x * scalefactor);  points2[0].y = points[1].y = ycenter - (int) (y * scalefactor);//local point (0,  //             1-ARROWLENGTHMULT,  //             -ARROWWIDTHMULT)  x = axisframe[0][1] * localy -    axisframe[0][2] * localz +    axisframe[0][3];  y = axisframe[1][1] * localy -    axisframe[1][2] * localz +    axisframe[1][3];  z = axisframe[2][1] * localy -    axisframe[2][2] * localz +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[2].x = points[2].x = xcenter + (int) (x * scalefactor);  points2[2].y = points[2].y = ycenter - (int) (y * scalefactor);  XFillPolygon (display, drawable, gc, points, 3, Convex, CoordModeOrigin);// local point (ARROWWIDTHHMULT,  //              1-ARROWLENGTHMULT,  //              0)  localx = arrowwidth;  localy = 1.0 - arrowlength;  x = axisframe[0][0] * localx +    axisframe[0][1] * localy +    axisframe[0][3];  y = axisframe[1][0] * localx +    axisframe[1][1] * localy +    axisframe[1][3];  z = axisframe[2][0] * localx +    axisframe[2][1] * localy +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[1].x = points[1].x = xcenter + (int) (x * scalefactor);  points2[1].y = points[1].y = ycenter - (int) (y * scalefactor);// local point (-ARROWWIDTHHMULT,  //              1-ARROWLENGTHMULT,  //              0)  x = -axisframe[0][0] * localx +    axisframe[0][1] * localy +    axisframe[0][3];  y = -axisframe[1][0] * localx +    axisframe[1][1] * localy +    axisframe[1][3];  z = -axisframe[2][0] * localx +    axisframe[2][1] * localy +    axisframe[2][3];  y = (y * eyedistance) / (eyedistance - z);  x = (x * eyedistance) / (eyedistance - z);  points2[3].x = points[2].x = xcenter + (int) (x * scalefactor);  points2[3].y = points[2].y = ycenter - (int) (y * scalefactor);  XFillPolygon (display, drawable, gc, points, 3, Convex, CoordModeOrigin);  XFillPolygon (display, drawable, gc, points2, 4, Convex, CoordModeOrigin);// last the arrows on Z-axis  //local point (0, 0, 1.0)  points[0].x = axis[3][0];  points[0].y = axis[3][1];

⌨️ 快捷键说明

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