Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SterownikRozmyty
- {
- public static class SI
- {
- public static List<List<int>> wartosciDlaX = new List<List<int>>();
- public static List<List<int>> wartosciDlaKata = new List<List<int>>();
- public static List<List<int>> wynikiRegul = new List<List<int>>();
- public static void inicjuj()
- {
- wartosciDlaX.Add(new List<int> { -100, 55 });
- wartosciDlaX.Add(new List<int> { 0, 20 });
- wartosciDlaX.Add(new List<int> { 100, 55 });
- wartosciDlaKata.Add(new List<int> { -180, 50 });
- wartosciDlaKata.Add(new List<int> { -90, 40 });
- wartosciDlaKata.Add(new List<int> { 0, 30 });
- wartosciDlaKata.Add(new List<int> { 90, 40 });
- wartosciDlaKata.Add(new List<int> { 180, 50 });
- wynikiRegul.Add(new List<int> { 20, 20, 20, 0, -20 });
- wynikiRegul.Add(new List<int> { 20, 20, 0, -20, -20 });
- wynikiRegul.Add(new List<int> { 20, 0, -20, -20, -20 });
- }
- public static void zwroc_odpowiedz(PojazdPolozenie polozenie, out int obrot)
- {
- double licznik = 0;
- double mianowink = 0;
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- var regula1 = zwroc_z_funkcji(polozenie.x, wartosciDlaX[i][0], wartosciDlaX[i][1]);
- var regula2 = zwroc_z_funkcji(polozenie.kat, wartosciDlaKata[j][0], wartosciDlaKata[j][1]);
- licznik += regula1 * regula2 * wynikiRegul[i][j];
- mianowink += regula1 * regula2;
- }
- }
- obrot = Convert.ToInt32(licznik / mianowink);
- }
- public static double zwroc_z_funkcji(double x, double max, double sigma)
- {
- return Math.Exp((((x - max) / sigma) * ((x - max) / sigma)) * -1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement