1 package org.djunits.unit.scale;
2
3
4
5
6
7
8
9
10
11
12
13
14 public class GradeScale implements Scale
15 {
16
17 private static final long serialVersionUID = 20151011L;
18
19
20 private final double conversionFactorToGrade;
21
22
23
24
25
26
27 public GradeScale(final double conversionFactorToGrade)
28 {
29 this.conversionFactorToGrade = conversionFactorToGrade;
30 }
31
32 @Override
33 public final double toStandardUnit(final double value)
34 {
35 return Math.atan(value * this.conversionFactorToGrade);
36 }
37
38 @Override
39 public final double fromStandardUnit(final double value)
40 {
41 return Math.tan(value) / this.conversionFactorToGrade;
42 }
43
44
45
46
47 public final double getConversionFactorToGrade()
48 {
49 return this.conversionFactorToGrade;
50 }
51
52 @Override
53 public boolean isBaseSIScale()
54 {
55 return false;
56 }
57
58 @Override
59 public int hashCode()
60 {
61 final int prime = 31;
62 int result = 1;
63 long temp;
64 temp = Double.doubleToLongBits(this.conversionFactorToGrade);
65 result = prime * result + (int) (temp ^ (temp >>> 32));
66 return result;
67 }
68
69 @SuppressWarnings("checkstyle:needbraces")
70 @Override
71 public boolean equals(final Object obj)
72 {
73 if (this == obj)
74 return true;
75 if (obj == null)
76 return false;
77 if (getClass() != obj.getClass())
78 return false;
79 GradeScale other = (GradeScale) obj;
80 if (Double.doubleToLongBits(this.conversionFactorToGrade) != Double.doubleToLongBits(other.conversionFactorToGrade))
81 return false;
82 return true;
83 }
84
85 @Override
86 public String toString()
87 {
88 return "GradeScale [conversionFactorToGrade=" + this.conversionFactorToGrade + "]";
89 }
90
91 }