Data Types
Brief
The article explains how to use the library data types
Details
The most of the data required for the ballistic calculations can be specified in different units in the different sources, e.g. velocity can be specified in feet per second or meters per second.
To make the library flexible and independent from the units for all critical data, such as:
Angle
Velocity
Weight
Energy
Distance
Atmospheric pressure
Temperature
the appropriate data type is used instead of using a regular double values.
All classes are just wrapper around double value and unit of measure, so the value and the unit of measure should be specified every time when a value is set. The value can be read in any of the supported unit of measure, regardless which unit was used when the value was specified.
Data values on the example of distance [hide]
| C# |
Distance d; d = new Distance(10, Distance.Unit.Inch); Console.WriteLine("{0}", d.Get(Distance.Unit.Inch)); Console.WriteLine("{0}", d.Get(Distance.Unit.Yard)); Console.WriteLine("{0}", d.Get(Distance.Unit.Meter));
When the data type is converted into string the name of the unit of measure is added to the value. Correspondingly, the name of the unit
is expected when the value is parsed from the string, i.e. 10 inch value in the string presentation is "10in" rather than just 10.
The data always are converted into the US locale (dot as a decimal point and comma as a thousands separator), regardless to the client settings.
The data types classes are located in the namespace MathEx.ExternalBallistic.Units