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

📄 makeellipse.cc

📁 模糊聚类分析的源程序!
💻 CC
字号:
#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <time.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;int i, j, Index, Anzahl, Dim;char Name[30];FILE *File;time_t timer;main (int argc, char *argv[]){  if (argc < 2) {    printf ("Dim(2/3),Punktanzahl,x-,y-(,z-)Mittelpunkt,x-,y-(,z-)Radius,Achse(x,y(,z)),um x,Name\n");    exit (0);  }  srand ((unsigned) time (&timer));  sscanf (argv[1], "%d", &Dim);  sscanf (argv[2], "%d", &Anzahl);  Index = 3;  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");  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]);      fprintf (File, "\n");      i++;    }  }  fclose (File);}

⌨️ 快捷键说明

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