1 | /* |
2 | * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences. |
3 | * Copyright (C) 2006 - JScience (http://jscience.org/) |
4 | * All rights reserved. |
5 | * |
6 | * Permission to use, copy, modify, and distribute this software is |
7 | * freely granted, provided that this notice is preserved. |
8 | */ |
9 | package javax.measure.unit; |
10 | |
11 | import java.util.Collections; |
12 | import java.util.HashSet; |
13 | import java.util.Set; |
14 | |
15 | import javax.measure.converter.LogConverter; |
16 | import javax.measure.converter.RationalConverter; |
17 | import javax.measure.quantity.*; |
18 | |
19 | import static javax.measure.unit.SI.*; |
20 | |
21 | /** |
22 | * <p> This class contains units that are not part of the International |
23 | * System of Units, that is, they are outside the SI, but are important |
24 | * and widely used.</p> |
25 | * |
26 | * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a> |
27 | * @version 4.2, August 26, 2007 |
28 | */ |
29 | public final class NonSI extends SystemOfUnits { |
30 | |
31 | /** |
32 | * Holds collection of NonSI units. |
33 | */ |
34 | private static HashSet<Unit<?>> UNITS = new HashSet<Unit<?>>(); |
35 | |
36 | /** |
37 | * Holds the standard gravity constant: 9.80665 m/s² exact. |
38 | */ |
39 | private static final int STANDARD_GRAVITY_DIVIDEND = 980665; |
40 | private static final int STANDARD_GRAVITY_DIVISOR = 100000; |
41 | |
42 | /** |
43 | * Holds the international foot: 0.3048 m exact. |
44 | */ |
45 | private static final int INTERNATIONAL_FOOT_DIVIDEND = 3048; |
46 | private static final int INTERNATIONAL_FOOT_DIViSOR = 10000; |
47 | |
48 | /** |
49 | * Holds the avoirdupois pound: 0.45359237 kg exact |
50 | */ |
51 | private static final int AVOIRDUPOIS_POUND_DIVIDEND = 45359237; |
52 | private static final int AVOIRDUPOIS_POUND_DIVISOR = 100000000; |
53 | |
54 | /** |
55 | * Holds the Avogadro constant. |
56 | */ |
57 | private static final double AVOGADRO_CONSTANT = 6.02214199e23; // (1/mol). |
58 | |
59 | /** |
60 | * Holds the electric charge of one electron. |
61 | */ |
62 | private static final double ELEMENTARY_CHARGE = 1.602176462e-19; // (C). |
63 | |
64 | /** |
65 | * Default constructor (prevents this class from being instantiated). |
66 | */ |
67 | private NonSI() { |
68 | } |
69 | |
70 | /** |
71 | * Returns the unique instance of this class. |
72 | * |
73 | * @return the NonSI instance. |
74 | */ |
75 | public static NonSI getInstance() { |
76 | return INSTANCE; |
77 | } |
78 | private static final NonSI INSTANCE = new NonSI(); |
79 | |
80 | /////////////////// |
81 | // Dimensionless // |
82 | /////////////////// |
83 | |
84 | /** |
85 | * A dimensionless unit equals to <code>0.01</code> |
86 | * (standard name <code>%</code>). |
87 | */ |
88 | public static final Unit<Dimensionless> PERCENT = nonSI(Unit.ONE.divide(100)); |
89 | |
90 | /** |
91 | * A logarithmic unit used to describe a ratio |
92 | * (standard name <code>dB</code>). |
93 | */ |
94 | public static final Unit<Dimensionless> DECIBEL = nonSI(Unit.ONE |
95 | .transform(new LogConverter(10).inverse().concatenate( |
96 | new RationalConverter(1, 10)))); |
97 | |
98 | ///////////////////////// |
99 | // Amount of substance // |
100 | ///////////////////////// |
101 | |
102 | /** |
103 | * A unit of amount of substance equals to one atom |
104 | * (standard name <code>atom</code>). |
105 | */ |
106 | public static final Unit<AmountOfSubstance> ATOM = nonSI(MOLE |
107 | .divide(AVOGADRO_CONSTANT)); |
108 | |
109 | //////////// |
110 | // Length // |
111 | //////////// |
112 | |
113 | /** |
114 | * A unit of length equal to <code>0.3048 m</code> |
115 | * (standard name <code>ft</code>). |
116 | */ |
117 | public static final Unit<Length> FOOT = nonSI(METRE.times(INTERNATIONAL_FOOT_DIVIDEND).divide(INTERNATIONAL_FOOT_DIViSOR)); |
118 | |
119 | /** |
120 | * A unit of length equal to <code>1200/3937 m</code> |
121 | * (standard name <code>foot_survey_us</code>). |
122 | * See also: <a href="http://www.sizes.com/units/foot.htm">foot</a> |
123 | */ |
124 | public static final Unit<Length> FOOT_SURVEY_US = nonSI(METRE |
125 | .times(1200).divide(3937)); |
126 | |
127 | /** |
128 | * A unit of length equal to <code>0.9144 m</code> |
129 | * (standard name <code>yd</code>). |
130 | */ |
131 | public static final Unit<Length> YARD = nonSI(FOOT.times(3)); |
132 | |
133 | /** |
134 | * A unit of length equal to <code>0.0254 m</code> |
135 | * (standard name <code>in</code>). |
136 | */ |
137 | public static final Unit<Length> INCH = nonSI(FOOT.divide(12)); |
138 | |
139 | /** |
140 | * A unit of length equal to <code>1609.344 m</code> |
141 | * (standard name <code>mi</code>). |
142 | */ |
143 | public static final Unit<Length> MILE = nonSI(METRE.times(1609344).divide(1000)); |
144 | |
145 | /** |
146 | * A unit of length equal to <code>1852.0 m</code> |
147 | * (standard name <code>nmi</code>). |
148 | */ |
149 | public static final Unit<Length> NAUTICAL_MILE = nonSI(METRE.times(1852)); |
150 | |
151 | /** |
152 | * A unit of length equal to <code>1E-10 m</code> |
153 | * (standard name <code>Å</code>). |
154 | */ |
155 | public static final Unit<Length> ANGSTROM = nonSI(METRE.divide(10000000000L)); |
156 | |
157 | /** |
158 | * A unit of length equal to the average distance from the center of the |
159 | * Earth to the center of the Sun (standard name <code>ua</code>). |
160 | */ |
161 | public static final Unit<Length> ASTRONOMICAL_UNIT = nonSI(METRE |
162 | .times(149597870691.0)); |
163 | |
164 | /** |
165 | * A unit of length equal to the distance that light travels in one year |
166 | * through a vacuum (standard name <code>ly</code>). |
167 | */ |
168 | public static final Unit<Length> LIGHT_YEAR = nonSI(METRE.times(9.460528405e15)); |
169 | |
170 | /** |
171 | * A unit of length equal to the distance at which a star would appear to |
172 | * shift its position by one arcsecond over the course the time |
173 | * (about 3 months) in which the Earth moves a distance of |
174 | * {@link #ASTRONOMICAL_UNIT} in the direction perpendicular to the |
175 | * direction to the star (standard name <code>pc</code>). |
176 | */ |
177 | public static final Unit<Length> PARSEC = nonSI(METRE.times(30856770e9)); |
178 | |
179 | /** |
180 | * A unit of length equal to <code>0.013837 {@link #INCH}</code> exactly |
181 | * (standard name <code>pt</code>). |
182 | * @see #PIXEL |
183 | */ |
184 | public static final Unit<Length> POINT = nonSI(INCH.times(13837).divide(1000000)); |
185 | |
186 | /** |
187 | * A unit of length equal to <code>1/72 {@link #INCH}</code> |
188 | * (standard name <code>pixel</code>). |
189 | * It is the American point rounded to an even 1/72 inch. |
190 | * @see #POINT |
191 | */ |
192 | public static final Unit<Length> PIXEL = nonSI(INCH.divide(72)); |
193 | |
194 | /** |
195 | * Equivalent {@link #PIXEL} |
196 | */ |
197 | public static final Unit<Length> COMPUTER_POINT = PIXEL; |
198 | |
199 | ////////////// |
200 | // Duration // |
201 | ////////////// |
202 | |
203 | /** |
204 | * A unit of duration equal to <code>60 s</code> |
205 | * (standard name <code>min</code>). |
206 | */ |
207 | public static final Unit<Duration> MINUTE = nonSI(SI.SECOND.times(60)); |
208 | |
209 | /** |
210 | * A unit of duration equal to <code>60 {@link #MINUTE}</code> |
211 | * (standard name <code>h</code>). |
212 | */ |
213 | public static final Unit<Duration> HOUR = nonSI(MINUTE.times(60)); |
214 | |
215 | /** |
216 | * A unit of duration equal to <code>24 {@link #HOUR}</code> |
217 | * (standard name <code>d</code>). |
218 | */ |
219 | public static final Unit<Duration> DAY = nonSI(HOUR.times(24)); |
220 | |
221 | /** |
222 | * A unit of duration equal to <code>7 {@link #DAY}</code> |
223 | * (standard name <code>week</code>). |
224 | */ |
225 | public static final Unit<Duration> WEEK = nonSI(DAY.times(7)); |
226 | |
227 | /** |
228 | * A unit of duration equal to 365 days, 5 hours, 49 minutes, |
229 | * and 12 seconds (standard name <code>year</code>). |
230 | */ |
231 | public static final Unit<Duration> YEAR = nonSI(SECOND.times(31556952)); |
232 | |
233 | /** |
234 | * A unit of duration equal to one twelfth of a year |
235 | * (standard name <code>month</code>). |
236 | */ |
237 | public static final Unit<Duration> MONTH = nonSI(YEAR.divide(12)); |
238 | |
239 | /** |
240 | * A unit of duration equal to the time required for a complete rotation of |
241 | * the earth in reference to any star or to the vernal equinox at the |
242 | * meridian, equal to 23 hours, 56 minutes, 4.09 seconds |
243 | * (standard name <code>day_sidereal</code>). |
244 | */ |
245 | public static final Unit<Duration> DAY_SIDEREAL = nonSI(SECOND.times(86164.09)); |
246 | |
247 | /** |
248 | * A unit of duration equal to one complete revolution of the |
249 | * earth about the sun, relative to the fixed stars, or 365 days, 6 hours, |
250 | * 9 minutes, 9.54 seconds (standard name <code>year_sidereal</code>). |
251 | */ |
252 | public static final Unit<Duration> YEAR_SIDEREAL = nonSI(SECOND |
253 | .times(31558149.54)); |
254 | |
255 | /** |
256 | * A unit of duration equal to <code>365 {@link #DAY}</code> |
257 | * (standard name <code>year_calendar</code>). |
258 | */ |
259 | public static final Unit<Duration> YEAR_CALENDAR = nonSI(DAY.times(365)); |
260 | |
261 | ////////// |
262 | // Mass // |
263 | ////////// |
264 | |
265 | /** |
266 | * A unit of mass equal to 1/12 the mass of the carbon-12 atom |
267 | * (standard name <code>u</code>). |
268 | */ |
269 | public static final Unit<Mass> ATOMIC_MASS = nonSI(KILOGRAM |
270 | .times(1e-3 / AVOGADRO_CONSTANT)); |
271 | |
272 | /** |
273 | * A unit of mass equal to the mass of the electron |
274 | * (standard name <code>me</code>). |
275 | */ |
276 | public static final Unit<Mass> ELECTRON_MASS = nonSI(KILOGRAM |
277 | .times(9.10938188e-31)); |
278 | |
279 | /** |
280 | * A unit of mass equal to <code>453.59237 grams</code> (avoirdupois pound, |
281 | * standard name <code>lb</code>). |
282 | */ |
283 | public static final Unit<Mass> POUND = nonSI(KILOGRAM.times(AVOIRDUPOIS_POUND_DIVIDEND).divide(AVOIRDUPOIS_POUND_DIVISOR)); |
284 | |
285 | /** |
286 | * A unit of mass equal to <code>1 / 16 {@link #POUND}</code> |
287 | * (standard name <code>oz</code>). |
288 | */ |
289 | public static final Unit<Mass> OUNCE = nonSI(POUND.divide(16)); |
290 | |
291 | /** |
292 | * A unit of mass equal to <code>2000 {@link #POUND}</code> (short ton, |
293 | * standard name <code>ton_us</code>). |
294 | */ |
295 | public static final Unit<Mass> TON_US = nonSI(POUND.times(2000)); |
296 | |
297 | /** |
298 | * A unit of mass equal to <code>2240 {@link #POUND}</code> (long ton, |
299 | * standard name <code>ton_uk</code>). |
300 | */ |
301 | public static final Unit<Mass> TON_UK = nonSI(POUND.times(2240)); |
302 | |
303 | /** |
304 | * A unit of mass equal to <code>1000 kg</code> (metric ton, |
305 | * standard name <code>t</code>). |
306 | */ |
307 | public static final Unit<Mass> METRIC_TON = nonSI(KILOGRAM.times(1000)); |
308 | |
309 | ///////////////////// |
310 | // Electric charge // |
311 | ///////////////////// |
312 | |
313 | /** |
314 | * A unit of electric charge equal to the charge on one electron |
315 | * (standard name <code>e</code>). |
316 | */ |
317 | public static final Unit<ElectricCharge> E = nonSI(COULOMB |
318 | .times(ELEMENTARY_CHARGE)); |
319 | |
320 | /** |
321 | * A unit of electric charge equal to equal to the product of Avogadro's |
322 | * number (see {@link SI#MOLE}) and the charge (1 e) on a single electron |
323 | * (standard name <code>Fd</code>). |
324 | */ |
325 | public static final Unit<ElectricCharge> FARADAY = nonSI(COULOMB |
326 | .times(ELEMENTARY_CHARGE * AVOGADRO_CONSTANT)); // e/mol |
327 | |
328 | /** |
329 | * A unit of electric charge which exerts a force of one dyne on an equal |
330 | * charge at a distance of one centimeter |
331 | * (standard name <code>Fr</code>). |
332 | */ |
333 | public static final Unit<ElectricCharge> FRANKLIN = nonSI(COULOMB |
334 | .times(3.3356e-10)); |
335 | |
336 | ///////////////// |
337 | // Temperature // |
338 | ///////////////// |
339 | |
340 | /** |
341 | * A unit of temperature equal to <code>5/9 °K</code> |
342 | * (standard name <code>°R</code>). |
343 | */ |
344 | public static final Unit<Temperature> RANKINE = nonSI(KELVIN.times(5).divide(9)); |
345 | |
346 | /** |
347 | * A unit of temperature equal to degree Rankine minus |
348 | * <code>459.67 °R</code> (standard name <code>°F</code>). |
349 | * @see #RANKINE |
350 | */ |
351 | public static final Unit<Temperature> FAHRENHEIT = nonSI(RANKINE.plus(459.67)); |
352 | |
353 | /////////// |
354 | // Angle // |
355 | /////////// |
356 | |
357 | /** |
358 | * A unit of angle equal to a full circle or <code>2<i>π</i> |
359 | * {@link SI#RADIAN}</code> (standard name <code>rev</code>). |
360 | */ |
361 | public static final Unit<Angle> REVOLUTION = nonSI(RADIAN.times(2.0 * Math.PI)); |
362 | |
363 | /** |
364 | * A unit of angle equal to <code>1/360 {@link #REVOLUTION}</code> |
365 | * (standard name <code>°</code>). |
366 | */ |
367 | public static final Unit<Angle> DEGREE_ANGLE = nonSI(REVOLUTION.divide(360)); |
368 | |
369 | /** |
370 | * A unit of angle equal to <code>1/60 {@link #DEGREE_ANGLE}</code> |
371 | * (standard name <code>′</code>). |
372 | */ |
373 | public static final Unit<Angle> MINUTE_ANGLE = nonSI(DEGREE_ANGLE.divide(60)); |
374 | |
375 | /** |
376 | * A unit of angle equal to <code>1/60 {@link #MINUTE_ANGLE}</code> |
377 | * (standard name <code>"</code>). |
378 | */ |
379 | public static final Unit<Angle> SECOND_ANGLE = nonSI(MINUTE_ANGLE.divide(60)); |
380 | |
381 | /** |
382 | * A unit of angle equal to <code>0.01 {@link SI#RADIAN}</code> |
383 | * (standard name <code>centiradian</code>). |
384 | */ |
385 | public static final Unit<Angle> CENTIRADIAN = nonSI(RADIAN.divide(100)); |
386 | |
387 | /** |
388 | * A unit of angle measure equal to <code>1/400 {@link #REVOLUTION}</code> |
389 | * (standard name <code>grade</code>). |
390 | */ |
391 | public static final Unit<Angle> GRADE = nonSI(REVOLUTION.divide(400)); |
392 | |
393 | ////////////// |
394 | // Velocity // |
395 | ////////////// |
396 | |
397 | /** |
398 | * A unit of velocity expressing the number of international {@link |
399 | * #MILE miles} per {@link #HOUR hour} (abbreviation <code>mph</code>). |
400 | */ |
401 | public static final Unit<Velocity> MILES_PER_HOUR |
402 | = nonSI(NonSI.MILE.divide(NonSI.HOUR)).asType(Velocity.class); |
403 | |
404 | /** |
405 | * A unit of velocity expressing the number of {@link SI#KILOMETRE} per |
406 | * {@link #HOUR hour}. |
407 | */ |
408 | public static final Unit<Velocity> KILOMETRES_PER_HOUR |
409 | = nonSI(SI.KILOMETRE.divide(NonSI.HOUR)).asType(Velocity.class); |
410 | |
411 | /** |
412 | * Equivalent to {@link #KILOMETRES_PER_HOUR}. |
413 | */ |
414 | public static final Unit<Velocity> KILOMETERS_PER_HOUR = KILOMETRES_PER_HOUR; |
415 | |
416 | /** |
417 | * A unit of velocity expressing the number of {@link #NAUTICAL_MILE |
418 | * nautical miles} per {@link #HOUR hour} (abbreviation <code>kn</code>). |
419 | */ |
420 | public static final Unit<Velocity> KNOT |
421 | = nonSI(NonSI.NAUTICAL_MILE.divide(NonSI.HOUR)).asType(Velocity.class); |
422 | |
423 | /** |
424 | * A unit of velocity to express the speed of an aircraft relative to |
425 | * the speed of sound (standard name <code>Mach</code>). |
426 | */ |
427 | public static final Unit<Velocity> MACH = nonSI(METRES_PER_SECOND.times(331.6)); |
428 | |
429 | /** |
430 | * A unit of velocity relative to the speed of light |
431 | * (standard name <code>c</code>). |
432 | */ |
433 | public static final Unit<Velocity> C = nonSI(METRES_PER_SECOND.times(299792458)); |
434 | |
435 | ////////////////// |
436 | // Acceleration // |
437 | ////////////////// |
438 | |
439 | /** |
440 | * A unit of acceleration equal to the gravity at the earth's surface |
441 | * (standard name <code>grav</code>). |
442 | */ |
443 | public static final Unit<Acceleration> G = nonSI(METRES_PER_SQUARE_SECOND |
444 | .times(STANDARD_GRAVITY_DIVIDEND).divide(STANDARD_GRAVITY_DIVISOR)); |
445 | |
446 | ////////// |
447 | // Area // |
448 | ////////// |
449 | |
450 | /** |
451 | * A unit of area equal to <code>100 m²</code> |
452 | * (standard name <code>a</code>). |
453 | */ |
454 | public static final Unit<Area> ARE = nonSI(SQUARE_METRE.times(100)); |
455 | |
456 | /** |
457 | * A unit of area equal to <code>100 {@link #ARE}</code> |
458 | * (standard name <code>ha</code>). |
459 | */ |
460 | public static final Unit<Area> HECTARE = nonSI(ARE.times(100)); // Exact. |
461 | |
462 | ///////////////// |
463 | // Data Amount // |
464 | ///////////////// |
465 | |
466 | /** |
467 | * A unit of data amount equal to <code>8 {@link SI#BIT}</code> |
468 | * (BinarY TErm, standard name <code>byte</code>). |
469 | */ |
470 | public static final Unit<DataAmount> BYTE = nonSI(BIT.times(8)); |
471 | |
472 | /** |
473 | * Equivalent {@link #BYTE} |
474 | */ |
475 | public static final Unit<DataAmount> OCTET = BYTE; |
476 | |
477 | |
478 | ////////////////////// |
479 | // Electric current // |
480 | ////////////////////// |
481 | |
482 | /** |
483 | * A unit of electric charge equal to the centimeter-gram-second |
484 | * electromagnetic unit of magnetomotive force, equal to <code>10/4 |
485 | * πampere-turn</code> (standard name <code>Gi</code>). |
486 | */ |
487 | public static final Unit<ElectricCurrent> GILBERT = nonSI(SI.AMPERE |
488 | .times(10.0 / (4.0 * Math.PI))); |
489 | |
490 | //////////// |
491 | // Energy // |
492 | //////////// |
493 | |
494 | /** |
495 | * A unit of energy equal to <code>1E-7 J</code> |
496 | * (standard name <code>erg</code>). |
497 | */ |
498 | public static final Unit<Energy> ERG = nonSI(JOULE.divide(10000000)); |
499 | |
500 | /** |
501 | * A unit of energy equal to one electron-volt (standard name |
502 | * <code>eV</code>, also recognized <code>keV, MeV, GeV</code>). |
503 | */ |
504 | public static final Unit<Energy> ELECTRON_VOLT = nonSI(JOULE |
505 | .times(ELEMENTARY_CHARGE)); |
506 | |
507 | ///////////////// |
508 | // Illuminance // |
509 | ///////////////// |
510 | |
511 | /** |
512 | * A unit of illuminance equal to <code>1E4 Lx</code> |
513 | * (standard name <code>La</code>). |
514 | */ |
515 | public static final Unit<Illuminance> LAMBERT = nonSI(LUX.times(10000)); |
516 | |
517 | /////////////////// |
518 | // Magnetic Flux // |
519 | /////////////////// |
520 | |
521 | /** |
522 | * A unit of magnetic flux equal <code>1E-8 Wb</code> |
523 | * (standard name <code>Mx</code>). |
524 | */ |
525 | public static final Unit<MagneticFlux> MAXWELL = nonSI(WEBER.divide(100000000)); |
526 | |
527 | /////////////////////////// |
528 | // Magnetic Flux Density // |
529 | /////////////////////////// |
530 | |
531 | /** |
532 | * A unit of magnetic flux density equal <code>1000 A/m</code> |
533 | * (standard name <code>G</code>). |
534 | */ |
535 | public static final Unit<MagneticFluxDensity> GAUSS = nonSI(TESLA.divide(10000)); |
536 | |
537 | /////////// |
538 | // Force // |
539 | /////////// |
540 | |
541 | /** |
542 | * A unit of force equal to <code>1E-5 N</code> |
543 | * (standard name <code>dyn</code>). |
544 | */ |
545 | public static final Unit<Force> DYNE = nonSI(NEWTON.divide(100000)); |
546 | |
547 | /** |
548 | * A unit of force equal to <code>9.80665 N</code> |
549 | * (standard name <code>kgf</code>). |
550 | */ |
551 | public static final Unit<Force> KILOGRAM_FORCE = nonSI(NEWTON |
552 | .times(STANDARD_GRAVITY_DIVIDEND).divide(STANDARD_GRAVITY_DIVISOR)); |
553 | |
554 | /** |
555 | * A unit of force equal to <code>{@link #POUND}·{@link #G}</code> |
556 | * (standard name <code>lbf</code>). |
557 | */ |
558 | public static final Unit<Force> POUND_FORCE = nonSI(NEWTON |
559 | .times(1L * AVOIRDUPOIS_POUND_DIVIDEND * STANDARD_GRAVITY_DIVIDEND).divide( |
560 | 1L * AVOIRDUPOIS_POUND_DIVISOR * STANDARD_GRAVITY_DIVISOR)); |
561 | |
562 | /////////// |
563 | // Power // |
564 | /////////// |
565 | |
566 | /** |
567 | * A unit of power equal to the power required to raise a mass of 75 |
568 | * kilograms at a velocity of 1 meter per second (metric, |
569 | * standard name <code>hp</code>). |
570 | */ |
571 | public static final Unit<Power> HORSEPOWER = nonSI(WATT.times(735.499)); |
572 | |
573 | ////////////// |
574 | // Pressure // |
575 | ////////////// |
576 | |
577 | /** |
578 | * A unit of pressure equal to the average pressure of the Earth's |
579 | * atmosphere at sea level (standard name <code>atm</code>). |
580 | */ |
581 | public static final Unit<Pressure> ATMOSPHERE = nonSI(PASCAL.times(101325)); |
582 | |
583 | /** |
584 | * A unit of pressure equal to <code>100 kPa</code> |
585 | * (standard name <code>bar</code>). |
586 | */ |
587 | public static final Unit<Pressure> BAR = nonSI(PASCAL.times(100000)); |
588 | |
589 | /** |
590 | * A unit of pressure equal to the pressure exerted at the Earth's |
591 | * surface by a column of mercury 1 millimeter high |
592 | * (standard name <code>mmHg</code>). |
593 | */ |
594 | public static final Unit<Pressure> MILLIMETER_OF_MERCURY =nonSI(PASCAL |
595 | .times(133.322)); |
596 | |
597 | /** |
598 | * A unit of pressure equal to the pressure exerted at the Earth's |
599 | * surface by a column of mercury 1 inch high |
600 | * (standard name <code>inHg</code>). |
601 | */ |
602 | public static final Unit<Pressure> INCH_OF_MERCURY = nonSI(PASCAL.times(3386.388)); |
603 | |
604 | ///////////////////////////// |
605 | // Radiation dose absorbed // |
606 | ///////////////////////////// |
607 | |
608 | /** |
609 | * A unit of radiation dose absorbed equal to a dose of 0.01 joule of |
610 | * energy per kilogram of mass (J/kg) (standard name <code>rd</code>). |
611 | */ |
612 | public static final Unit<RadiationDoseAbsorbed> RAD = nonSI(GRAY.divide(100)); |
613 | |
614 | /** |
615 | * A unit of radiation dose effective equal to <code>0.01 Sv</code> |
616 | * (standard name <code>rem</code>). |
617 | */ |
618 | public static final Unit<RadiationDoseEffective> REM = nonSI(SIEVERT.divide(100)); |
619 | |
620 | ////////////////////////// |
621 | // Radioactive activity // |
622 | ////////////////////////// |
623 | |
624 | /** |
625 | * A unit of radioctive activity equal to the activity of a gram of radium |
626 | * (standard name <code>Ci</code>). |
627 | */ |
628 | public static final Unit<RadioactiveActivity> CURIE = nonSI(BECQUEREL |
629 | .times(37000000000L)); |
630 | |
631 | /** |
632 | * A unit of radioctive activity equal to 1 million radioactive |
633 | * disintegrations per second (standard name <code>Rd</code>). |
634 | */ |
635 | public static final Unit<RadioactiveActivity> RUTHERFORD = nonSI(SI.BECQUEREL |
636 | .times(1000000)); |
637 | |
638 | ///////////////// |
639 | // Solid angle // |
640 | ///////////////// |
641 | |
642 | /** |
643 | * A unit of solid angle equal to <code>4 <i>π</i> steradians</code> |
644 | * (standard name <code>sphere</code>). |
645 | */ |
646 | public static final Unit<SolidAngle> SPHERE = nonSI(STERADIAN |
647 | .times(4.0 * Math.PI)); |
648 | |
649 | //////////// |
650 | // Volume // |
651 | //////////// |
652 | |
653 | /** |
654 | * A unit of volume equal to one cubic decimeter (default label |
655 | * <code>L</code>, also recognized <code>µL, mL, cL, dL</code>). |
656 | */ |
657 | public static final Unit<Volume> LITRE = nonSI(CUBIC_METRE.divide(1000)); |
658 | |
659 | /** |
660 | * Equivalent to {@link #LITRE} (American spelling). |
661 | */ |
662 | public static final Unit<Volume> LITER = LITRE; |
663 | |
664 | /** |
665 | * A unit of volume equal to one cubic inch (<code>in³</code>). |
666 | */ |
667 | public static final Unit<Volume> CUBIC_INCH = nonSI( |
668 | INCH.pow(3).asType(Volume.class)); |
669 | |
670 | /** |
671 | * A unit of volume equal to one US gallon, Liquid Unit. The U.S. liquid |
672 | * gallon is based on the Queen Anne or Wine gallon occupying 231 cubic |
673 | * inches (standard name <code>gal</code>). |
674 | */ |
675 | public static final Unit<Volume> GALLON_LIQUID_US = nonSI(CUBIC_INCH.times(231)); |
676 | |
677 | /** |
678 | * A unit of volume equal to <code>1 / 128 {@link #GALLON_LIQUID_US}</code> |
679 | * (standard name <code>oz_fl</code>). |
680 | */ |
681 | public static final Unit<Volume> OUNCE_LIQUID_US = nonSI(GALLON_LIQUID_US |
682 | .divide(128)); |
683 | |
684 | /** |
685 | * A unit of volume equal to one US dry gallon. |
686 | * (standard name <code>gallon_dry_us</code>). |
687 | */ |
688 | public static final Unit<Volume> GALLON_DRY_US = nonSI(CUBIC_INCH.times(2688025).divide(10000)); |
689 | |
690 | /** |
691 | * A unit of volume equal to <code>4.546 09 {@link #LITRE}</code> |
692 | * (standard name <code>gal_uk</code>). |
693 | */ |
694 | public static final Unit<Volume> GALLON_UK = nonSI(LITRE.times(454609).divide(100000)); |
695 | |
696 | /** |
697 | * A unit of volume equal to <code>1 / 160 {@link #GALLON_UK}</code> |
698 | * (standard name <code>oz_fl_uk</code>). |
699 | */ |
700 | public static final Unit<Volume> OUNCE_LIQUID_UK = nonSI(GALLON_UK.divide(160)); |
701 | |
702 | /////////////// |
703 | // Viscosity // |
704 | /////////////// |
705 | |
706 | /** |
707 | * A unit of dynamic viscosity equal to <code>1 g/(cm·s)</code> |
708 | * (cgs unit). |
709 | */ |
710 | @SuppressWarnings("unchecked") |
711 | public static final Unit<DynamicViscosity> |
712 | POISE = nonSI((Unit<DynamicViscosity>) GRAM.divide(CENTI(METRE).times(SECOND))); |
713 | |
714 | /** |
715 | * A unit of kinematic viscosity equal to <code>1 cm²/s</code> |
716 | * (cgs unit). |
717 | */ |
718 | @SuppressWarnings("unchecked") |
719 | public static final Unit<KinematicViscosity> |
720 | STOKE = nonSI((Unit<KinematicViscosity>) CENTI(METRE).pow(2).divide(SECOND)); |
721 | |
722 | |
723 | //////////// |
724 | // Others // |
725 | //////////// |
726 | |
727 | /** |
728 | * A unit used to measure the ionizing ability of radiation |
729 | * (standard name <code>Roentgen</code>). |
730 | */ |
731 | public static final Unit<?> ROENTGEN = nonSI(COULOMB.divide(KILOGRAM).times(2.58e-4)); |
732 | |
733 | |
734 | ///////////////////// |
735 | // Collection View // |
736 | ///////////////////// |
737 | |
738 | /** |
739 | * Returns a read only view over the units defined in this class. |
740 | * |
741 | * @return the collection of NonSI units. |
742 | */ |
743 | public Set<Unit<?>> getUnits() { |
744 | return Collections.unmodifiableSet(UNITS); |
745 | } |
746 | |
747 | /** |
748 | * Adds a new unit to the collection. |
749 | * |
750 | * @param unit the unit being added. |
751 | * @return <code>unit</code>. |
752 | */ |
753 | private static <U extends Unit<?>> U nonSI(U unit) { |
754 | UNITS.add(unit); |
755 | return unit; |
756 | } |
757 | |
758 | } |