Project Description
NPhysics - Physical Data Types for .NET

How to Create a Physical Value

The easierst way to create a Physical Value is to use the Extension Methods for a double. The Extension Method creates a new instance of the generic type PhysicalValue<T>.

using IMaverick.Physics;
using IMaverick.Physics.Extensions;

var meter = 2.5.m();
var kg =;

Creation of a Physical Value without Extension Methods

using IMaverick.Physics;

var meter = new PhysicalValue<Length>(2.5, Length.Meter);
var kg = new PhysicalValue<Weight>(23.2, Weight.Kilogram);

Physical Value Members

Member Description
Unit Returns the unit class used by the Physical Value. e.g. Length.Meter
UnitString Returns the SI unit symbol as string. e.g. m
Value Returns the value of the Physical Value. e.g. 2.5
EqualsApproximately Used to compare two Physical Values with a tolernce. e.g. 2.0.m().EqualsApproximately(1.98.m(), 0.05.m())
ScaleTo() Scales a Physical Value to a specific unit. e.g. 200.0.m().ScaleTo(Length.Kilometer)
ToDefault() Scales a Physical Value to the default SI unit. e.g. //The Physical Value has now the Value 200 and the Unit Length.Meter
ToString() ToString is overloaded, that it return the value and the unit symbol. e.g. 200 m

Available Units

Unit Group Units
Acceleration MeterPerSecond
Angle Degree, Radian, Grade, Brad
AngularVelocity DegreePerSecond, RadianPerSecond, RotationsPerMinute, RotationsPerSecond
Current Ampere, Kiloampere, Milliampere, Microampere
Frequency Hertz, Kilohertz, Megahertz, Gigahertz, Decihertz, Centihertz, Millihertz, Microhertz
Length Meter, Kilometer, Decimeter, Centimeter, Millimeter, Micrometer
Power Newton
Pressure Pascal, Kilopascal, Hectopascal, Bar, Millibar
Temperature Kelvin, Celsius, Fahrenheit
Time Second, Millisecond, Microsecond, Minute, Hour, Day, Month, Year
Torque Newtonmeter
Velocity MeterPerSecond, CentimeterPerSecond, KilometerPerHour, MilesPerHour
Voltage Volt, Kilovolt, Millivolt, Microvolt
Weight Gram, Kilogram, Ton, Milligram, Microgram

Last edited Feb 28, 2011 at 12:02 PM by SvenImaverick, version 15