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
33 @Override
34 public final double toStandardUnit(final double value)
35 {
36 return Math.atan(value * this.conversionFactorToGrade);
37 }
38
39
40 @Override
41 public final double fromStandardUnit(final double value)
42 {
43 return Math.tan(value) / this.conversionFactorToGrade;
44 }
45
46
47
48
49 public final double getConversionFactorToGrade()
50 {
51 return this.conversionFactorToGrade;
52 }
53
54
55 @Override
56 public boolean isBaseSIScale()
57 {
58 return false;
59 }
60
61
62 @Override
63 public int hashCode()
64 {
65 final int prime = 31;
66 int result = 1;
67 long temp;
68 temp = Double.doubleToLongBits(this.conversionFactorToGrade);
69 result = prime * result + (int) (temp ^ (temp >>> 32));
70 return result;
71 }
72
73
74 @SuppressWarnings("checkstyle:needbraces")
75 @Override
76 public boolean equals(final Object obj)
77 {
78 if (this == obj)
79 return true;
80 if (obj == null)
81 return false;
82 if (getClass() != obj.getClass())
83 return false;
84 GradeScale../../../org/djunits/unit/scale/GradeScale.html#GradeScale">GradeScale other = (GradeScale) obj;
85 if (Double.doubleToLongBits(this.conversionFactorToGrade) != Double.doubleToLongBits(other.conversionFactorToGrade))
86 return false;
87 return true;
88 }
89
90
91 @Override
92 public String toString()
93 {
94 return "GradeScale [conversionFactorToGrade=" + this.conversionFactorToGrade + "]";
95 }
96
97 }