Материал: Определение количества витков резьбового соединения с трапецеидальной резьбой, воспринимающего осевую сжимающую нагрузку

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

if (coord_do[i].c != Color.Black)

{

strw.WriteLine("" + Solution.Answer[listGI[i].ind[0] * 2+1]);

strw.WriteLine("" + Solution.Answer[listGI[i].ind[1] * 2+1]);

strw.WriteLine("" + Solution.Answer[listGI[i].ind[2] * 2+1]);

}

strw.Close();

button3.Visible = true;

button2.Visible = true;

}

MessageBox.Show("Максимальное абсолютное откланение " + sm);

}void button2_Click(object sender, EventArgs e)

{

Form2 f = new Form2(coord_do, listGI);

f.ShowDialog();

}

private void button3_Click(object sender, EventArgs e)

{

Form2 form = new Form2(list_coord_rez, listGI);

form.ShowDialog();

}

private void Form1_Load(object sender, EventArgs e)

{

}

}

}

Form2.csSystem;System.Collections.Generic;System.ComponentModel;System.Data;System.Drawing;System.Threading;System.Text;System.Windows.Forms;WindowsFormsApplication1

{

public partial class Form2 : Form

{

List<Uzl_Coord> l = new List<Uzl_Coord>();

List<globindexes> u = new List<globindexes>();

double maxx = 0;

double maxy = 0;

double minx = double.MaxValue, miny = double.MaxValue;

int indminx = 0, indmaxx = 0, indminy = 0, indmaxy = 0;

public Form2(List<Uzl_Coord> lc,List<globindexes>uz)

{

InitializeComponent();

l = lc;

u = uz;(int i = 0; i < lc.Count; i++)

{

if (lc[i].c != Color.Black)

{

if (maxx < lc[i].x1)

{ maxx = lc[i].x1; indmaxx = i; }

if (maxx < lc[i].x2)

{ maxx = lc[i].x2; indmaxx = i; }

if (maxx < lc[i].x3)

{ maxx = lc[i].x3; indmaxx = i; }

if (maxy < lc[i].y1)

{ maxy = lc[i].y1; indmaxy = i; }

if (maxy < lc[i].y2)

{ maxy = lc[i].y2; indmaxy = i; }

if (maxy < lc[i].y3)

{ maxy = lc[i].y3; indmaxy = i; }

if (minx > lc[i].x1)

{ minx = lc[i].x1; indminx = i; }

if (minx > lc[i].x2)

{ minx = lc[i].x2; indminx = i; }

if (minx > lc[i].x3)

{ minx = lc[i].x3; indminx = i; }

if (miny > lc[i].y1)

{ miny = lc[i].y1; indminy = i; }

if (miny > lc[i].y2)

{ miny = lc[i].y2; indminy = i; }

if (miny > lc[i].y3)

{ miny = lc[i].y3; indminy = i; }

}

}

this.Click += new EventHandler(Form2_Click);

this.Width = (int)(maxx-minx+2)*20+40;

this.Height = (int)(maxy-miny+2)*20+40 ;

MessageBox.Show(maxx+" "+maxy);

}

void Form2_Click(object sender, EventArgs e)

{

Graphics g = this.CreateGraphics();

Pen p = new Pen(Color.Black, 1);

SolidBrush br;

for (int i = 0; i < u.Count; i++)(l[i].c!=Color.Black){

br = new SolidBrush(l[i].c);

Point pnt1 = new Point((int)(l[i].x1 * 20 +20+ Math.Abs(minx)*20), this.Height - 55 - (int)((l[i].y1 * 20) - miny*20));

Point pnt2 = new Point((int)(l[i].x2 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (int)((l[i].y2 * 20) - miny * 20));

Point pnt3 = new Point((int)(l[i].x3 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (int)((l[i].y3 * 20) - miny * 20));

Point[] arrp = { pnt1, pnt2, pnt3 };

g.FillPolygon(br, arrp);

g.DrawLine(p, (float)(l[i].x1 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (float)(l[i].y1 * 20 - miny * 20), (float)(l[i].x2 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (float)(l[i].y2 * 20 - miny * 20));

g.DrawLine(p, (float)(l[i].x1 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (float)(l[i].y1 * 20 - miny * 20), (float)(l[i].x3 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (float)(l[i].y3 * 20 - miny * 20));

g.DrawLine(p, (float)(l[i].x3 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (float)(l[i].y3 * 20 - miny * 20), (float)(l[i].x2 * 20 + 20 + Math.Abs(minx) * 20), this.Height - 55 - (float)(l[i].y2 * 20 - miny * 20));.csSystem;System.Collections.Generic;System.Text;System.Drawing;WindowsFormsApplication1

{

class Rezba

{

static public double D;//диаметр шляпки

static public double b;//ширина шляпки

static public double l;//длина конца болта

static public double d1;//внутренний диаметр

static public double d2;//средний диаметр

static public double d3;//внешний диаметр

static public double bg;//ширина гайки

static public double lg;//длина гайки

static public double p;//шаг резьбы

static public double H;//рабочая высота

static public int count_v;//кол-во витков

static public double eps;//точность

}

public class Uzl_Coord

{

public double x1;

public double x2;

public double x3;

public double y1;

public double y2;

public double y3;

public Color c;

}

class matrAclass

{

public double[,] A;

}

class matrKLOCclass

{

public double[,] K;

}

public class globindexes

{

public int[] ind;

}

//// Метод Гаусса ////GausMethod

{

public int RowCount;

public int ColumCount;

public double[,] Matrix;

public double[] RightPart;

public double[] Answer;

public GausMethod(int count)

{

RightPart = new double[count];

Answer = new double[count];

Matrix = new double[count, count];

RowCount = count;

ColumCount = count;

//обнулим массив

for (int i = 0; i < count; i++)

{

Answer[i] = 0;

RightPart[i] = 0;

for (int j = 0; j < count; j++)

Matrix[i, j] = 0;

}

}

private void SortRows(int SortIndex)

{

double MaxElement = Matrix[SortIndex, SortIndex];

int MaxElementIndex = SortIndex;

for (int i = SortIndex + 1; i < RowCount; i++)

{

if (Matrix[i, SortIndex] > MaxElement)

{

MaxElement = Matrix[i, SortIndex];

MaxElementIndex = i;

}

}

//теперь найден максимальный элемент ставим его на верхнее место

if (MaxElementIndex > SortIndex)//если это не первый элемент

{

double Temp;

Temp = RightPart[MaxElementIndex];

RightPart[MaxElementIndex] = RightPart[SortIndex];

RightPart[SortIndex] = Temp;

for (int i = 0; i < ColumCount; i++)

{

Temp = Matrix[MaxElementIndex, i];

Matrix[MaxElementIndex, i] = Matrix[SortIndex, i];

Matrix[SortIndex, i] = Temp;

}

}

}

public int SolveMatrix()

{

if (RowCount != ColumCount)

return 1; //нет решения

for (int i = 0; i < RowCount - 1; i++)

{

SortRows(i);

 for (int j = i + 1; j < RowCount; j++)

{

if (Matrix[i, i] != 0) //если главный элемент не 0, то производим вычисления

{

double MultElement = Matrix[j, i] / Matrix[i, i];

for (int k = i; k < ColumCount; k++)

Matrix[j, k] -= Matrix[i, k] * MultElement;

RightPart[j] -= RightPart[i] * MultElement;

}

//для нулевого главного элемента просто пропускаем данный шаг

}

}

//ищем решение

for (int i = (int)(RowCount - 1); i >= 0; i--)

{

Answer[i] = RightPart[i];

for (int j = (int)(RowCount - 1); j > i; j--)

Answer[i] -= Matrix[i, j] * Answer[j];

if (Matrix[i, i] == 0)

if (RightPart[i] == 0)

return 2; //множество решений

else

return 1; //нет решения

Answer[i] /= Matrix[i, i];

}

return 0;

}

public override String ToString()

{

String S = "";

for (int i = 0; i < RowCount; i++)

{

S += "\r\n";

for (int j = 0; j < ColumCount; j++)

{

S += Matrix[i, j].ToString("F04") + "\t";

}

S += "\t" + Answer[i].ToString("F08");

S += "\t" + RightPart[i].ToString("F04");

}

return S;

}

}

}