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

UnitReturns the unit class used by the Physical Value. e.g. Length.Meter
UnitStringReturns the SI unit symbol as string. e.g. m
ValueReturns the value of the Physical Value. e.g. 2.5
EqualsApproximatelyUsed 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
AngleDegree, Radian, Grade, Brad
AngularVelocityDegreePerSecond, RadianPerSecond, RotationsPerMinute, RotationsPerSecond
CurrentAmpere, Kiloampere, Milliampere, Microampere
FrequencyHertz, Kilohertz, Megahertz, Gigahertz, Decihertz, Centihertz, Millihertz, Microhertz
LengthMeter, Kilometer, Decimeter, Centimeter, Millimeter, Micrometer
PressurePascal, Kilopascal, Hectopascal, Bar, Millibar
TemperatureKelvin, Celsius, Fahrenheit
TimeSecond, Millisecond, Microsecond, Minute, Hour, Day, Month, Year
VelocityMeterPerSecond, CentimeterPerSecond, KilometerPerHour, MilesPerHour
VoltageVolt, Kilovolt, Millivolt, Microvolt
WeightGram, Kilogram, Ton, Milligram, Microgram

Last edited Feb 28, 2011 at 11:02 AM by SvenImaverick, version 15