« Units management » : différence entre les versions

De GENIUS
Aller à la navigation Aller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 6 : Ligne 6 :
</syntaxhighlight>
</syntaxhighlight>


In case of using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GMetricUnit.html|GMetricUnit], when we define a unit for a real value, it is stored automatically in the computer memory in '''International System (IS)''' (m, kg, rad …).
In case of using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GMetricUnit.html GMetricUnit], when we define a unit for a real value, it is stored automatically in the computer memory in '''International System (IS)''' (m, kg, rad …).


<syntaxhighlight lang="java">                     
<syntaxhighlight lang="java">                     

Version du 5 mai 2017 à 09:13

Units are managed with the GUnit class or more directly with GMetricUnit.

// To display a menu allowing to display kilometers (km) or Nautic Miles (nmi)
GUnit[] unitDis = { new GMetricUnit ("km") , new GMetricUnit ("nmi") };

In case of using GMetricUnit, when we define a unit for a real value, it is stored automatically in the computer memory in International System (IS) (m, kg, rad …).

                    
dist  = new GEntryReal("Distance", 1000., unitDis); // Initialization with 1000 meters.

Thus, in that case, we may have a difference between what it is displayed (for example 1.0 km) and what it is actually stored in the memory (1000.).

Units.jpg

To get the value stored in memory (same for an integer even if there is no units for it), we will use the getValue() method:

double val = dist.getValue(); // Allways in IS

The basic IS units given by default by GENIUS are the following:

  • kilogram (kg)
  • meter (m)
  • second (s)
  • Amper (A)

Of course, GENIUS proposes also angular units with radian (rad) for IS to be convertible in degree (deg).

Then, it is possible to get composed units using "." for multiplication, "/" for division or "^'" for power (a negative power is enabled). Thus, we may have kg.m/s^2 (or kg.m.s^-2) as a composed unit.

Allways about composed units, GENIUS proposes the following ones:

  • Steradians (m2.m-2) => sr
  • Hertz (s-1) => Hz
  • Newton (kg.m.s-2) => N
  • Pascal (N.m-2) => Pa
  • Joules (N.m) => J
  • Watt (J.s-1) => W
  • Coulomb (A.s) => C
  • Volt (W.A-1) => V
  • Farad (C.V-1) => F
  • Ohm (V.A-1) => R

For more facilities, these units have also been added:

  • gramm = 0.001*kg => g
  • ton = 1000 kg => t
  • minutes = 60 s => mn
  • hour = 3600 s => h
  • day = 86400 => j

It is also possible to use coefficients:

  • T: Tera = 1012
  • G : Giga = 109
  • M: Mega = 106
  • k: kilo = 103
  • h: hecto = 102
  • da: deca = 10
  • d: deci = 10-1
  • c: centi = 10-2
  • m: mili = 10-3
  • u: micro = 10-6
  • n: nano = 10-9
  • p: pico = 10-12

Note that for mass values, these coefficient will be applied on "g" and not "kg".

So, we could have something as mg.dam/mn^2 ... for something equivalent as (1/36)10-6 Newtons !

At last, for not proportional conversions, GENIUS proposes anyway to convert:


Return to the introduction ↑ Go to the next page →