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

📄 make_ellipse.cc

📁 模糊聚类分析的源程序!
💻 CC
字号:
/********************************************************//*   filename: make_ellipse.cc                          *//*                                                      *//********************************************************//* programmed by: Oliver Wagner                         *//* last change: 22-03-95                                *//********************************************************/#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <time.h>#include "daten.h"#include "vektor.h"#include "matrix.h"DVektor Mitte (3, 0, NULL), Radius (3, 0, NULL), Achse (3, 0, NULL), Result (3, 0, NULL),  Wert (3, 0, NULL);DMatrix Rot (3, 3, NULL), Rot2 (3, 3, NULL);double Um_x, Um_y, Um_z, Abstand;Daten_Typ Typ;int i, j, Index, Anzahl, Dim, Klasse;char Name[30];FILE *File;time_t timer;main (int argc, char *argv[]){  if (argc < 2) {    printf ("Typ(0=Normal,1=Klassifiziert(=>zus. Klassennummer)),Dim(2/3),\n");    printf ("Punktanzahl,x-,y-(,z-)Mittelpunkt,x-,y-(,z-)Radius,Achse(x,y(,z)),um x,Name\n");    exit (0);  }  srand ((unsigned) time (&timer));  Index = 1;  sscanf (argv[Index++], "%d", &Typ);  if (Typ == Klassifiziert)    sscanf (argv[Index++], "%d", &Klasse);  sscanf (argv[Index++], "%d", &Dim);  sscanf (argv[Index++], "%d", &Anzahl);  for (j = 0; j < Dim; j++)    sscanf (argv[Index++], "%lf", &Mitte[j]);  for (j = 0; j < Dim; j++)    sscanf (argv[Index++], "%lf", &Radius[j]);  for (j = 0; j < Dim; j++)    sscanf (argv[Index++], "%lf", &Achse[j]);  sscanf (argv[Index++], "%lf", &Um_x);  sscanf (argv[Index], "%s", Name);/* Achsen berechnen */  Achse.Normiere ();  Um_y = atan2 (Achse[2], Achse[0]);  Um_z = atan2 (Achse[1], sqrt (Achse[0] * Achse[0] + Achse[2] * Achse[2]));  /* Zuerst um y */  Rot2 = d3_yRot (Um_y);  Rot = d3_zRot (Um_z);  Rot = Rot * Rot2;  Rot2 = d3_xRot (Um_x);  Rot = Rot * Rot2;//  Rot=Rot.Gauss_Inverse();/**************************/  File = fopen (Name, "w");  switch (Typ) {  case Normal:    fprintf (File, "normal\n");    break;  case Klassifiziert:    fprintf (File, "classified\n");    break;  }  fprintf (File, "%d %d %d\n", Anzahl, Dim - 1, 1);  if (Dim == 2)    fprintf (File, "x y\n");  else    fprintf (File, "x y z\n");  i = 0;  while (i < Anzahl) {    for (j = 0; j < Dim; j++)      Wert[j] = -2 * Radius[j] + 4 * Radius[j] * (((double) rand ()) / (double) RAND_MAX);    Abstand = 0;    for (j = 0; j < Dim; j++)      Abstand += Wert[j] * Wert[j] / (Radius[j] * Radius[j]);    if (Abstand <= 1) {      Result = Rot * Wert;      for (j = 0; j < Dim; j++)	fprintf (File, "%f ", Result[j] + Mitte[j]);      if (Typ == Klassifiziert)	fprintf (File, "%d\n", Klasse);      else	fprintf (File, "\n");      i++;    }  }  fclose (File);}

⌨️ 快捷键说明

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