1 9 package org.jscience.physics.quantities; 10 import javolution.lang.MathLib; 11 12 import org.jscience.physics.units.SI; 13 import org.jscience.physics.units.Unit; 14 15 23 public class Dimensionless extends Quantity { 24 25 28 private final static Unit<Dimensionless> UNIT = Unit.ONE; 29 30 33 private final static Factory<Dimensionless> FACTORY = new Factory<Dimensionless>( 34 UNIT) { 35 protected Dimensionless create() { 36 return new Dimensionless(); 37 } 38 }; 39 40 43 public final static Dimensionless ZERO = Quantity.valueOf(0, UNIT); 44 45 48 public final static Dimensionless ONE = Quantity.valueOf(1, UNIT); 49 50 53 public static final Dimensionless e = Quantity.valueOf(MathLib.E, UNIT); 54 55 58 protected Dimensionless() { 59 } 60 61 67 public static Dimensionless valueOf(double doubleValue) { 68 return Quantity.valueOf(doubleValue, Unit.ONE); 69 } 70 71 76 public static void showAs(Unit unit) { 77 QuantityFormat.show(Dimensionless.class, unit); 78 } 79 80 81 85 91 public Dimensionless exp() { 92 return Quantity.valueOf( 93 MathLib.exp(getMinimum()), MathLib.exp(getMaximum()), UNIT); 94 } 95 96 101 public Dimensionless log() { 102 return Quantity.valueOf( 103 MathLib.log(getMinimum()), MathLib.log(getMaximum()), UNIT); 104 } 105 106 113 public Dimensionless pow(Dimensionless exp) { 114 Dimensionless system = to(Unit.ONE); 115 double min = system.getMinimum(); 116 double max = system.getMaximum(); 117 return Quantity.valueOf( 118 MathLib.pow(getMinimum(), exp.getMinimum()), 119 MathLib.pow(getMaximum(), exp.getMaximum()), UNIT); 120 } 121 122 127 public Angle asin() { 128 double min = getMinimum(); 129 double max = getMaximum(); 130 if (min < -1.0) { 131 min = -1; 132 } 133 if (max > 1.0) { 134 max = 1; 135 } 136 return Quantity.valueOf( 137 MathLib.asin(min), MathLib.asin(max), SI.RADIAN); 138 } 139 140 145 public Angle acos() { 146 double min = getMinimum(); 147 double max = getMaximum(); 148 if (min < -1.0) { 149 min = -1; 150 } 151 if (max > 1.0) { 152 max = 1; 153 } 154 return Quantity.valueOf( 155 MathLib.acos(max), MathLib.acos(min), SI.RADIAN); 156 } 157 158 163 public Angle atan() { 164 return Angle.atan2(this, ONE); 165 } 166 167 private static final long serialVersionUID = 1L; 168 } 169 | Popular Tags |