Description
Provides conversion utilities.
Public Methods
Example
Convert a position to another representation
[C#] |
---|
IAgConversionUtility converter = root.ConversionUtility;
// ConvertPositionArray expects a two dimensional array of positions
Array cartesianPositions = new object[,]
{
{ 1216.47, -4736.12, 4081.39 },
{ 1000, -2000, 2000 }
};
// Convert cartesian dates to cylindrical
// ConvertPositionArray returns a two dimensional array of cartesian dates
Array cylindricalPositions = converter.ConvertPositionArray(AgEPositionType.eCartesian, ref cartesianPositions, AgEPositionType.eCylindrical);
// Print results
for (int i = 0; i < cylindricalPositions.GetLength(0); i++)
{
Console.WriteLine("X: {0}, Y: {1}, Z: {2}",
cylindricalPositions.GetValue(i, 0),
cylindricalPositions.GetValue(i, 1),
cylindricalPositions.GetValue(i, 2));
}
|
|
Convert a quantity unit to another unit
[C#] |
---|
IAgConversionUtility converter = root.ConversionUtility;
// Old value in miles, new value in km
double newValue = converter.ConvertQuantity("DistanceUnit", "mi", "km", 1.0);
|
|
Convert mulitple quantities of the same unit to another unit
[C#] |
---|
IAgConversionUtility converter = root.ConversionUtility;
// ConvertQuantityArray expects a one dimensional array of values to be converted
// An array of km/sec units
Array kmsecUnits = new object[]
{
100, 23
};
// Convert to mi/sec units
// ConvertQuantityArray returns a one dimensional array of converted values
Array misecUnits = converter.ConvertQuantityArray("Rate", "km/sec", "mi/sec", ref kmsecUnits);
|
|
Convert a date format to another format
[C#] |
---|
IAgConversionUtility converter = root.ConversionUtility;
// Individually
string epsec = converter.ConvertDate("UTCG", "Epsec", "1 Jan 2012 12:00:00.000");
string utcg = converter.ConvertDate("EpSec", "UTCG", "230126401.000");
|
|
Convert multiple dates of the same format to another format
[C#] |
---|
IAgConversionUtility converter = root.ConversionUtility;
// In batches
// ConvertDateArray expects a one dimensional array of dates
// An array of UTCG dates
Array tempDates = new object[]
{
"1 Jan 2012 12:00:00.000", "1 Jan 2012 14:00:00.000"
};
// Convert UTCG array to EpSec
// ConvertDateArray returns a one dimensional array of converted dates
Array converted = converter.ConvertDateArray("UTCG", "Epsec", ref tempDates);
// Print results
for (int i = 0; i < converted.Length; i++)
{
Console.WriteLine("Date: {0}", converted.GetValue(i));
}
|
|
Convert a position to another representation
[Visual Basic .NET] |
---|
Dim converter As IAgConversionUtility = root.ConversionUtility
' ConvertPositionArray expects a two dimensional array of positions
Dim cartesianPositions As Array = New Object(,) {{1216.47, -4736.12, 4081.39}, {1000, -2000, 2000}}
' Convert cartesian dates to cylindrical
' ConvertPositionArray returns a two dimensional array of cartesian dates
Dim cylindricalPositions As Array = converter.ConvertPositionArray(AgEPositionType.eCartesian, cartesianPositions, AgEPositionType.eCylindrical)
' Print results
Dim i As Integer = 0
While i < cylindricalPositions.GetLength(0)
Console.WriteLine("X: {0}, Y: {1}, Z: {2}", cylindricalPositions.GetValue(i, 0), cylindricalPositions.GetValue(i, 1), cylindricalPositions.GetValue(i, 2))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
|
|
Convert a quantity unit to another unit
[Visual Basic .NET] |
---|
Dim converter As IAgConversionUtility = root.ConversionUtility
' Old value in miles, new value in km
Dim newValue As Double = converter.ConvertQuantity("DistanceUnit", "mi", "km", 1)
|
|
Convert mulitple quantities of the same unit to another unit
[Visual Basic .NET] |
---|
Dim converter As IAgConversionUtility = root.ConversionUtility
' ConvertQuantityArray expects a one dimensional array of values to be converted
' An array of km/sec units
Dim kmsecUnits As Array = New Object() {100, 23}
' Convert to mi/sec units
' ConvertQuantityArray returns a one dimensional array of converted values
Dim misecUnits As Array = converter.ConvertQuantityArray("Rate", "km/sec", "mi/sec", kmsecUnits)
|
|
Convert a date format to another format
[Visual Basic .NET] |
---|
Dim converter As IAgConversionUtility = root.ConversionUtility
' Individually
Dim epsec As String = converter.ConvertDate("UTCG", "Epsec", "1 Jan 2012 12:00:00.000")
Dim utcg As String = converter.ConvertDate("EpSec", "UTCG", "230126401.000")
|
|
Convert multiple dates of the same format to another format
[Visual Basic .NET] |
---|
Dim converter As IAgConversionUtility = root.ConversionUtility
' In batches
' ConvertDateArray expects a one dimensional array of dates
' An array of UTCG dates
Dim tempDates As Array = New Object() {"1 Jan 2012 12:00:00.000", "1 Jan 2012 14:00:00.000"}
' Convert UTCG array to EpSec
' ConvertDateArray returns a one dimensional array of converted dates
Dim converted As Array = converter.ConvertDateArray("UTCG", "Epsec", tempDates)
' Print results
Dim i As Integer = 0
While i < converted.Length
Console.WriteLine("Date: {0}", converted.GetValue(i))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
|
|