Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace Ingres
- {
- class Point
- {
- double x;
- double y;
- bool[] Connection;
- public Point(double x,double y,bool[]Connections)
- {
- this.x = x;
- this.y = y;
- for(int i=0;i<Connections.Length;i++)
- {
- Connection[i] = Connections[i];
- }
- }
- public double getX()
- {
- return x;
- }
- public double getY()
- {
- return y;
- }
- }
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- public void Input(out int[] Array_Out_X, out int[] Array_Out_Y)
- {
- string[] x = File.ReadAllText("portals1.csv").Split(';');
- double[] Arrayx;
- double[] Arrayy;
- int sizeOfTheInput = x.GetLength(0);
- sizeOfTheInput--;
- if (sizeOfTheInput % 2 == 0)
- {
- Arrayx = new double[sizeOfTheInput / 2];
- Arrayy = new double[sizeOfTheInput / 2];
- Array_Out_X = new int[sizeOfTheInput / 2];
- Array_Out_Y = new int[sizeOfTheInput / 2];
- }
- else
- {
- Arrayx = new double[sizeOfTheInput / 2 + 1];
- Arrayy = new double[sizeOfTheInput / 2 + 1];
- Array_Out_Y = new int[sizeOfTheInput / 2 + 1];
- Array_Out_X = new int[sizeOfTheInput / 2+1];
- }
- for (int i = 2, j = 0; j < x.GetLength(0); i = i + 2, j++)
- {
- try
- {
- Arrayy[j] = Convert.ToDouble(x[i].Split('\r')[0]);
- }
- catch { };
- }
- for (int i = 1, j = 0; j < x.GetLength(0); i = i + 2, j++)
- {
- try
- {
- Arrayx[j] = Convert.ToDouble(x[i].Split('\r')[0]);
- }
- catch { };
- }
- //Нормализация
- double minX = FindMin(Arrayx);
- double minY=FindMin(Arrayy);
- for (int i = 0; i < Arrayx.Length; i++)
- {
- Array_Out_X[i] = Convert.ToInt32((Arrayx[i] - minX) * 100000);
- }
- for (int i = 0; i < Arrayy.Length; i++)
- {
- Array_Out_Y[i] = Convert.ToInt32((Arrayy[i] - minY) * 100000);
- }
- }
- public double FindMin(double []Array)
- {
- double min = 100000;
- for(int i=0;i<Array.Length;i++)
- {
- if (min > Array[i])
- min = Array[i];
- }
- return min;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- int[] Arrayx;
- int[] Arrayy;
- Input(out Arrayx, out Arrayy);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement