C# Class YAMP.Physics.CombinedUnit

Used to represent combined units -- temporary and defined.
Inheritance: PhysicalUnit
Show file Open project: FlorianRappl/YAMP Class Usage Examples

Public Methods

Method Description
CombinedUnit ( String unit ) : System
ConvertTo ( String unit ) : Double>>.List

Tries to convert the unit to the given unit.

CreateFrom ( String unit ) : CombinedUnit
Divide ( CombinedUnit unit ) : CombinedUnit

Divides the given combined unit by another unit.

Divide ( String unit ) : CombinedUnit

Divides the given combined unit by the string representation of another unit.

Multiply ( CombinedUnit unit ) : CombinedUnit

Multiplies the given combined unit with another combined unit.

Multiply ( String unit ) : CombinedUnit

Multiplies the given combined unit with the string representation of another unit.

Raise ( Double pwr ) : CombinedUnit

Raises the current unit to the specified power, i.e. kg*s --> raised to 2 is kg^2 * s^2.

Simplify ( ) : CombinedUnit

Tries to simplify the current expression by considering combined types.

Sqrt ( ) : CombinedUnit

Takes the square root of the current unit, i.e. raises it to the power 1/2.

ToString ( ) : String
Unpack ( ) : String

Unpacks the given units, i.e. returns the representation of the unit in elementary units.

Protected Methods

Method Description
CombinedUnit ( String combination, Double factor ) : System
Create ( ) : PhysicalUnit
IsNumber ( char ch ) : bool
IsWhiteSpace ( char ch ) : bool

Private Methods

Method Description
AddUnit ( Double>.Dictionary units, String unit, Double exp ) : void
ConvertToDouble ( String s ) : Double
ConvertToInteger ( string s ) : int
Count ( Token token, Token tokens ) : Int32
EatWhile ( Token token, Token tokens, String text, Int32 start ) : String
FindMapping ( String source, Double>.Dictionary target, Int32 sign, Double>.List list ) : String
GetChanges ( CombinedUnit unit, System.Boolean &reversed ) : Double
GetToken ( char ch ) : Token
Parse ( String unit ) : Double>.Dictionary
Parse ( String unit, Double>.Dictionary units ) : void

Method Details

CombinedUnit() public method

public CombinedUnit ( String unit ) : System
unit String
return System

CombinedUnit() protected method

protected CombinedUnit ( String combination, Double factor ) : System
combination String
factor Double
return System

ConvertTo() public method

Tries to convert the unit to the given unit.
public ConvertTo ( String unit ) : Double>>.List
unit String The unit (combination) to convert to.
return Double>>.List

Create() protected method

protected Create ( ) : PhysicalUnit
return PhysicalUnit

CreateFrom() public method

public CreateFrom ( String unit ) : CombinedUnit
unit String
return CombinedUnit

Divide() public method

Divides the given combined unit by another unit.
public Divide ( CombinedUnit unit ) : CombinedUnit
unit CombinedUnit The combined unit to divide the current unit.
return CombinedUnit

Divide() public method

Divides the given combined unit by the string representation of another unit.
public Divide ( String unit ) : CombinedUnit
unit String The combined unit to divide the current unit.
return CombinedUnit

IsNumber() protected method

protected IsNumber ( char ch ) : bool
ch char
return bool

IsWhiteSpace() protected method

protected IsWhiteSpace ( char ch ) : bool
ch char
return bool

Multiply() public method

Multiplies the given combined unit with another combined unit.
public Multiply ( CombinedUnit unit ) : CombinedUnit
unit CombinedUnit The combined unit which is multiplied to the current unit.
return CombinedUnit

Multiply() public method

Multiplies the given combined unit with the string representation of another unit.
public Multiply ( String unit ) : CombinedUnit
unit String The unit to multiply the current unit with.
return CombinedUnit

Raise() public method

Raises the current unit to the specified power, i.e. kg*s --> raised to 2 is kg^2 * s^2.
public Raise ( Double pwr ) : CombinedUnit
pwr Double The power to raise the unit with.
return CombinedUnit

Simplify() public method

Tries to simplify the current expression by considering combined types.
public Simplify ( ) : CombinedUnit
return CombinedUnit

Sqrt() public method

Takes the square root of the current unit, i.e. raises it to the power 1/2.
public Sqrt ( ) : CombinedUnit
return CombinedUnit

ToString() public method

public ToString ( ) : String
return String

Unpack() public method

Unpacks the given units, i.e. returns the representation of the unit in elementary units.
public Unpack ( ) : String
return String