Skip to content

Commit 6a8ce4f

Browse files
#TDP - 11 Fixed bug
1. accuracy up to two characters 2. Delete point to line tringle
1 parent c5d867d commit 6a8ce4f

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

MethodMonte_Karlo/InteractionForm.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ System::Void MethodMonteKarlo::InteractionForm::Btn_squareTringle(System::Object
143143
this->chart1->Series[3]->Points->AddXY(rnd_x[i], rnd_y[i]);
144144
}
145145
double squareFigure = (M * a * b) / N;
146-
this->label_squareTringle->Text = "Ïëîùàäü: " + squareFigure.ToString();
147-
this->label_checkSquare->Text = " Ïðîâåðêà: " + (0.5 * abs((triangleVertexCoord ["xc"]- triangleVertexCoord["xa"])*
148-
(triangleVertexCoord["yb"]- triangleVertexCoord["ya"])-(triangleVertexCoord["xb"]- triangleVertexCoord["xa"])
149-
*(triangleVertexCoord["yc"]- triangleVertexCoord["ya"]))).ToString();
146+
double squareTringle = (0.5 * abs((triangleVertexCoord["xc"] - triangleVertexCoord["xa"]) *
147+
(triangleVertexCoord["yb"] - triangleVertexCoord["ya"]) - (triangleVertexCoord["xb"] - triangleVertexCoord["xa"])
148+
* (triangleVertexCoord["yc"] - triangleVertexCoord["ya"])));
149+
this->label_squareTringle->Text = "Ïëîùàäü: " + (int((squareFigure) * 1000 + 0.5) / 1000.0).ToString();
150+
this->label_checkSquare->Text = " Òî÷íîå çíà÷åíèå: " + (int((squareTringle) * 1000 + 0.5) / 1000.0).ToString();
150151
}
151152

152153
System::Void MethodMonteKarlo::InteractionForm::Btn_squareIntegral_Click(System::Object^ sender, System::EventArgs^ e)
@@ -205,8 +206,8 @@ System::Void MethodMonteKarlo::InteractionForm::Btn_squareIntegral_Click(System:
205206
this->chart1->Series[6]->Points->AddXY(rnd_x[i], rnd_y[i]);
206207
}
207208
double integral = (M * a * b) / N;
208-
this->label_integral->Text = "Èíòåãðàë: " + integral.ToString();
209-
this->label_checkIntegral->Text = " Ñèìïñîí: " + method_Sympsona(0.0, a, N, numVar, false);//method_LeftRectangle(0.0, a, N).ToString();
209+
this->label_integral->Text = "Èíòåãðàë: " + (int((integral) * 1000 + 0.5) / 1000.0).ToString();
210+
this->label_checkIntegral->Text = " Ñèìïñîí: " + (int((method_Sympsona(0.0, a, N, numVar, false)) * 1000 + 0.5) / 1000.0);//method_LeftRectangle(0.0, a, N).ToString();
210211
}
211212

212213
System::Void MethodMonteKarlo::InteractionForm::ToolStripMenuItem_openForm2_Click(System::Object^ sender, System::EventArgs^ e)

MethodMonte_Karlo/InteractionForm.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ namespace MethodMonteKarlo {
312312
static_cast<System::Byte>(204)));
313313
series1->Legend = L"Legend1";
314314
series1->MarkerColor = System::Drawing::Color::Red;
315-
series1->MarkerStyle = System::Windows::Forms::DataVisualization::Charting::MarkerStyle::Square;
316315
series1->Name = L"Ôèãóðà";
317316
series2->BorderWidth = 2;
318317
series2->ChartArea = L"ChartArea1";
@@ -343,12 +342,11 @@ namespace MethodMonteKarlo {
343342
series4->Name = L"Òî÷êè ñíàðóæè";
344343
series5->BorderWidth = 2;
345344
series5->ChartArea = L"ChartArea2";
346-
series5->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::SplineArea;
345+
series5->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Spline;
347346
series5->Color = System::Drawing::Color::Transparent;
348347
series5->Legend = L"Legend2";
349348
series5->MarkerColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(0)),
350349
static_cast<System::Int32>(static_cast<System::Byte>(0)));
351-
series5->MarkerStyle = System::Windows::Forms::DataVisualization::Charting::MarkerStyle::Circle;
352350
series5->Name = L"Ôèãóðà-2";
353351
series5->Palette = System::Windows::Forms::DataVisualization::Charting::ChartColorPalette::Grayscale;
354352
series5->YValuesPerPoint = 2;

MethodMonte_Karlo/InteractiveForm2.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ System::Void MethodMonteKarlo::InteractiveForm2::Button1_Click(System::Object^ s
4242
double squareCicle = 4 * M / N;
4343
this->label_pi->Text = "ÏÈ : " + (std::_Pi).ToString();
4444
this->label_squareSquare->Text = "Ïëîùàäü êâàäðàòà : " + (squareSquare).ToString();
45-
this->label_squareCicle->Text = "Ïëîùàäü êðóãà : " + (squareCicle).ToString();
45+
this->label_squareCicle->Text = "Ïëîùàäü êðóãà : " + (int((squareCicle) * 1000 + 0.5) / 1000.0).ToString();
4646
}
4747

4848
void MethodMonteKarlo::InteractiveForm2::clearInteractiveElementChartArea1()
@@ -134,10 +134,11 @@ System::Void MethodMonteKarlo::InteractiveForm2::Btn_polar_Click(System::Object^
134134
else
135135
this->chart1->Series[7]->Points->AddXY(rnd_x[i], rnd_y[i]);
136136
}
137-
138-
this->label_squareFigure->Text = "Ïëîùàäü ôèãóðû " + (M * (max_a * max_b * 4.0) / N).ToString();
139-
this->label_check1->Text = "PI/2 *(" +A.ToString() + " + " + B.ToString() +") " + ((std::_Pi/2.0) * (A + B)).ToString();
140-
this->label_checkIntegral->Text = "Èíòåãðàë: " +(0.5*(method_Sympsona(0,std::_Pi*2.0,N,numVar,true))).ToString();
137+
double squireFigure = int(((M * (max_a * max_b * 4.0) / N)) * 1000 + 0.5) / 1000.0;
138+
double accu = int((0.5 * (method_Sympsona(0, std::_Pi * 2.0, N, numVar, true))) * 1000 + 0.5) / 1000.0;
139+
this->label_squareFigure->Text = "Ïëîùàäü ôèãóðû " + squireFigure.ToString();//(M * (max_a * max_b * 4.0) / N).ToString();
140+
this->label_check1->Text = "PI/2 *(" +A.ToString() + " + " + B.ToString() +") " + (int(((std::_Pi / 2.0) * (A + B)) * 1000 + 0.5) / 1000.0).ToString();
141+
this->label_checkIntegral->Text = "Òî÷íîå çíà÷åíèå: " + accu.ToString();//(0.5*(method_Sympsona(0,std::_Pi*2.0,N,numVar,true))).ToString();
141142
//this->label_checkIntegral->Text += " LEFT " + (0.5*(method_LeftRectangle(0,std::_Pi*2.0,N))).ToString();
142143
}
143144

MethodMonte_Karlo/InteractiveForm2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ namespace MethodMonteKarlo {
370370
// label_check1
371371
//
372372
this->label_check1->AutoSize = true;
373-
this->label_check1->Location = System::Drawing::Point(650, 191);
373+
this->label_check1->Location = System::Drawing::Point(650, 290);
374374
this->label_check1->Name = L"label_check1";
375375
this->label_check1->Size = System::Drawing::Size(112, 13);
376376
this->label_check1->TabIndex = 13;
@@ -429,7 +429,7 @@ namespace MethodMonteKarlo {
429429
// label_checkIntegral
430430
//
431431
this->label_checkIntegral->AutoSize = true;
432-
this->label_checkIntegral->Location = System::Drawing::Point(650, 222);
432+
this->label_checkIntegral->Location = System::Drawing::Point(650, 197);
433433
this->label_checkIntegral->Name = L"label_checkIntegral";
434434
this->label_checkIntegral->Size = System::Drawing::Size(55, 13);
435435
this->label_checkIntegral->TabIndex = 18;

0 commit comments

Comments
 (0)