1 package eu.fbk.shell.mdfsa.data.structures;
2
3 import java.io.Serializable;
4
5 public class FuzzyMembership implements Serializable {
6
7 private static final long serialVersionUID = 1L;
8
9 private double a;
10 private double b;
11 private double c;
12 private double d;
13
14 public FuzzyMembership(double a, double b, double c, double d) {
15 this.a = a;
16 this.b = b;
17 this.c = c;
18 this.d = d;
19 }
20
21
22 public double getA() {
23 return a;
24 }
25
26 public void setA(double a) {
27 this.a = a;
28 }
29
30 public double getB() {
31 return b;
32 }
33
34 public void setB(double b) {
35 this.b = b;
36 }
37
38 public double getC() {
39 return c;
40 }
41
42 public void setC(double c) {
43 this.c = c;
44 }
45
46 public double getD() {
47 return d;
48 }
49
50 public void setD(double d) {
51 this.d = d;
52 }
53
54 public double getCentroid(double oldFlag) {
55 double centroid = (this.b + this.c) / 2.0;
56
57
58
59 return centroid;
60 }
61
62 public double getCentroid() {
63 double centroid = 0.0;
64
65 if(this.b == this.d) {
66 centroid = this.b;
67 } else if(this.a == this.c) {
68 centroid = this.a;
69 } else {
70 double xCoeffR1 = 1 / (this.b - this.d);
71 double yCoeffR1 = 1.0;
72 double cCoeffR1 = (this.d / (this.b - this.d)) * -1;
73 double xCoeffR2 = 1 / (this.c - this.a);
74 double yCoeffR2 = 1.0;
75 double cCoeffR2 = (this.a / (this.c - this.a)) * -1;
76 double x = (cCoeffR1 - cCoeffR2) / (xCoeffR1 - xCoeffR2);
77 centroid = x;
78 }
79
80 return centroid;
81 }
82
83
84
85 public double getCentroidXAxis() {
86 double centroid = 0.0;
87
88 double num = (c * c) + (d * d) + (c * d) - (a * a) - (b * b) - (a * b);
89 double den = 3 * (c + d - a - b);
90 centroid = num / den;
91
92 return centroid;
93 }
94
95 }