1 9 package org.jscience.physics.units; 10 11 import org.jscience.physics.quantities.*; 12 13 29 public final class SI { 30 31 34 private SI() { 35 } 36 37 41 49 public static final BaseUnit<ElectricCurrent> AMPERE = new BaseUnit<ElectricCurrent>( 50 "A", Dimension.ELECTRIC_CURRENT, Converter.IDENTITY); 51 52 59 public static final BaseUnit<LuminousIntensity> CANDELA = new BaseUnit<LuminousIntensity>( 60 "cd", Dimension.LUMINOUS_INTENSITY, Converter.IDENTITY); 61 62 68 public static final BaseUnit<Temperature> KELVIN = new BaseUnit<Temperature>( 69 "K", Dimension.TEMPERATURE, Converter.IDENTITY); 70 71 78 public static final BaseUnit<Mass> KILOGRAM = new BaseUnit<Mass>("kg", 79 Dimension.MASS, Converter.IDENTITY); 80 81 86 public static final BaseUnit<Length> METER = new BaseUnit<Length>("m", 87 Dimension.LENGTH, Converter.IDENTITY); 88 89 94 public static final BaseUnit<AmountOfSubstance> MOLE = new BaseUnit<AmountOfSubstance>( 95 "mol", Dimension.AMOUNT_OF_SUBSTANCE, Converter.IDENTITY); 96 97 103 public static final BaseUnit<Duration> SECOND = new BaseUnit<Duration>("s", 104 Dimension.TIME, Converter.IDENTITY); 105 106 110 114 public static final Unit<Mass> GRAM = KILOGRAM.times(1e-3); 115 116 121 public static final Unit<Angle> RADIAN = Unit.ONE.alternate("rad"); 122 123 129 public static final Unit<SolidAngle> STERADIAN = Unit.ONE.alternate("sr"); 130 131 134 public static final Unit<DataAmount> BIT = Unit.ONE.alternate("bit"); 135 136 142 public static final Unit<Frequency> HERTZ = Unit.ONE.divide(SECOND) 143 .alternate("Hz"); 144 145 151 public static final Unit<Force> NEWTON = METER.times(KILOGRAM).divide( 152 SECOND.pow(2)).alternate("N"); 153 154 159 public static final Unit<Pressure> PASCAL = NEWTON.divide(METER.pow(2)) 160 .alternate("Pa"); 161 162 168 public static final Unit<Energy> JOULE = NEWTON.times(METER).alternate("J"); 169 170 175 public static final Unit<Power> WATT = JOULE.divide(SECOND).alternate("W"); 176 177 184 public static final Unit<ElectricCharge> COULOMB = SECOND.times(AMPERE) 185 .alternate("C"); 186 187 195 public static final Unit<ElectricPotential> VOLT = WATT.divide(AMPERE) 196 .alternate("V"); 197 198 205 public static final Unit<ElectricCapacitance> FARAD = COULOMB.divide(VOLT) 206 .alternate("F"); 207 208 214 public static final Unit<ElectricResistance> OHM = VOLT.divide(AMPERE) 215 .alternate("Ω"); 216 217 222 public static final Unit<ElectricConductance> SIEMENS = AMPERE.divide(VOLT) 223 .alternate("S"); 224 225 232 public static final Unit<MagneticFlux> WEBER = VOLT.times(SECOND) 233 .alternate("Wb"); 234 235 241 public static final Unit<MagneticFluxDensity> TESLA = WEBER.divide( 242 METER.pow(2)).alternate("T"); 243 244 251 public static final Unit<ElectricInductance> HENRY = WEBER.divide(AMPERE) 252 .alternate("H"); 253 254 260 public static final Unit<Temperature> CELSIUS = KELVIN.plus(273.15); 261 262 267 public static final Unit<LuminousFlux> LUMEN = CANDELA.times(STERADIAN) 268 .alternate("lm"); 269 270 274 public static final Unit<Illuminance> LUX = LUMEN.divide(METER.pow(2)) 275 .alternate("lx"); 276 277 283 public static final Unit<RadioactiveActivity> BECQUEREL = Unit.ONE.divide( 284 SECOND).alternate("Bq"); 285 286 293 public static final Unit<RadiationDoseAbsorbed> GRAY = JOULE.divide( 294 KILOGRAM).alternate("Gy"); 295 296 303 public static final Unit<RadiationDoseEffective> SIEVERT = JOULE.divide( 304 KILOGRAM).alternate("Sv"); 305 306 309 public static final Unit<CatalyticActivity> KATAL = MOLE.divide(SECOND) 310 .alternate("kat"); 311 312 316 319 public static final Unit<Velocity> METER_PER_SECOND = METER.divide(SECOND); 320 321 324 public static final Unit<Acceleration> METER_PER_SQUARE_SECOND = METER 325 .divide(SECOND.pow(2)); 326 327 330 public static final Unit<Area> SQUARE_METER = METER.pow(2); 331 332 335 public static final Unit<Volume> CUBIC_METER = METER.pow(3); 336 337 341 348 public static <Q extends Quantity> Unit<Q> YOTTA(Unit<Q> unit) { 349 return unit.times(1e24); 350 } 351 352 359 public static <Q extends Quantity> Unit<Q> ZETTA(Unit<Q> unit) { 360 return unit.times(1e21); 361 } 362 363 370 public static <Q extends Quantity> Unit<Q> EXA(Unit<Q> unit) { 371 return unit.times(1e18); 372 } 373 374 381 public static <Q extends Quantity> Unit<Q> PETA(Unit<Q> unit) { 382 return unit.times(1e15); 383 } 384 385 392 public static <Q extends Quantity> Unit<Q> TERA(Unit<Q> unit) { 393 return unit.times(1e12); 394 } 395 396 403 public static <Q extends Quantity> Unit<Q> GIGA(Unit<Q> unit) { 404 return unit.times(1e9); 405 } 406 407 414 public static <Q extends Quantity> Unit<Q> MEGA(Unit<Q> unit) { 415 return unit.times(1e6); 416 } 417 418 425 public static <Q extends Quantity> Unit<Q> KILO(Unit<Q> unit) { 426 return unit.times(1e3); 427 } 428 429 436 public static <Q extends Quantity> Unit<Q> HECTO(Unit<Q> unit) { 437 return unit.times(1e2); 438 } 439 440 447 public static <Q extends Quantity> Unit<Q> DEKA(Unit<Q> unit) { 448 return unit.times(1e1); 449 } 450 451 458 public static <Q extends Quantity> Unit<Q> DECI(Unit<Q> unit) { 459 return unit.times(1e-1); 460 } 461 462 469 public static <Q extends Quantity> Unit<Q> CENTI(Unit<Q> unit) { 470 return unit.times(1e-2); 471 } 472 473 480 public static <Q extends Quantity> Unit<Q> MILLI(Unit<Q> unit) { 481 return unit.times(1e-3); 482 } 483 484 491 public static <Q extends Quantity> Unit<Q> MICRO(Unit<Q> unit) { 492 return unit.times(1e-6); 493 } 494 495 502 public static <Q extends Quantity> Unit<Q> NANO(Unit<Q> unit) { 503 return unit.times(1e-9); 504 } 505 506 513 public static <Q extends Quantity> Unit<Q> PICO(Unit<Q> unit) { 514 return unit.times(1e-12); 515 } 516 517 524 public static <Q extends Quantity> Unit<Q> FEMTO(Unit<Q> unit) { 525 return unit.times(1e-15); 526 } 527 528 535 public static <Q extends Quantity> Unit<Q> ATTO(Unit<Q> unit) { 536 return unit.times(1e-18); 537 } 538 539 546 public static <Q extends Quantity> Unit<Q> ZEPTO(Unit<Q> unit) { 547 return unit.times(1e-21); 548 } 549 550 557 public static <Q extends Quantity> Unit<Q> YOCTO(Unit<Q> unit) { 558 return unit.times(1e-24); 559 } 560 561 private static final Unit[] SI_UNITS = { SI.AMPERE, SI.BECQUEREL, 564 SI.CANDELA, SI.COULOMB, SI.FARAD, SI.GRAY, SI.HENRY, SI.HERTZ, 565 SI.JOULE, SI.KATAL, SI.KELVIN, SI.LUMEN, SI.LUX, SI.METER, SI.MOLE, 566 SI.NEWTON, SI.OHM, SI.PASCAL, SI.RADIAN, SI.SECOND, SI.SIEMENS, 567 SI.SIEVERT, SI.STERADIAN, SI.TESLA, SI.VOLT, SI.WATT, SI.WEBER }; 568 569 private static final String [] PREFIXES = { "Y", "Z", "E", "P", "T", "G", 570 "M", "k", "h", "da", "d", "c", "m", "µ", "n", "p", "f", "a", "z", 571 "y" }; 572 573 private static final double[] FACTORS = { 1e24, 1e21, 1e18, 1e15, 1e12, 574 1e9, 1e6, 1e3, 1e2, 1e1, 1e-1, 1e-2, 1e-3, 1e-6, 1e-9, 1e-12, 575 1e-15, 1e-18, 1e-21, 1e-24 }; 576 static { 577 for (int i = 0; i < SI_UNITS.length; i++) { 578 for (int j = 0; j < PREFIXES.length; j++) { 579 Unit u = SI_UNITS[i].times(FACTORS[j]); 580 u.label(PREFIXES[j] + SI_UNITS[i]._symbol); 581 } 582 } 583 SI.GRAM.label("g"); 585 for (int i = 0; i < PREFIXES.length; i++) { 586 if (FACTORS[i] != 1e3) { SI.KILOGRAM.times(FACTORS[i] * 1e-3).label(PREFIXES[i] + "g"); 588 } 589 } 590 591 SI.CELSIUS.label("°C"); 593 for (int i = 0; i < PREFIXES.length; i++) { 594 SI.CELSIUS.times(FACTORS[i]).label(PREFIXES[i] + "°C"); 595 } 596 } 597 598 600 603 static void initializeClass() { 604 } 605 606 } | Popular Tags |