本文整理汇总了C#中System.Coordinate.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinate.ToArray方法的具体用法?C# Coordinate.ToArray怎么用?C# Coordinate.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Coordinate
的用法示例。
在下文中一共展示了Coordinate.ToArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HyperDistance
/// <summary>
/// Returns the distance that is appropriate for N dimensions. In otherwords, if this point is
/// three dimensional, then all three dimensions will be used for calculating the distance.
/// </summary>
/// <param name="coordinate">The coordinate to compare to this coordinate</param>
/// <returns>A double valued distance measure that is invariant to the number of coordinates</returns>
/// <exception cref="CoordinateMismatchException">The number of dimensions does not match between the points.</exception>
public double HyperDistance(Coordinate coordinate)
{
if (coordinate.NumOrdinates != NumOrdinates) throw new CoordinateMismatchException();
double sqrDist = 0;
double[] vals = coordinate.ToArray();
for (int i = 0; i < NumOrdinates; i++)
{
double diff = vals[i] - Coordinate[i];
sqrDist += diff * diff;
}
return Math.Sqrt(sqrDist);
}
示例2: HyperDistance
/// <summary>
/// Returns the distance that is appropriate for N dimensions. In otherwords, if this point is
/// three dimensional, then all three dimensions will be used for calculating the distance.
/// </summary>
/// <param name="coordinate">The coordinate to compare to this coordinate</param>
/// <returns>A double valued distance measure that is invariant to the number of coordinates</returns>
/// <exception cref="CoordinateMismatchException">The number of dimensions does not match between the points.</exception>
public double HyperDistance(Coordinate coordinate)
{
if (coordinate.NumOrdinates != NumOrdinates) throw new CoordinateMismatchException();
double[] vals = coordinate.ToArray();
double diff = vals[0] - Convert.ToDouble(_x);
double sqrDist = diff * diff;
diff = vals[1] - Convert.ToDouble(_y);
sqrDist += diff * diff;
diff = vals[2] - Convert.ToDouble(_z);
sqrDist += diff * diff;
return Math.Sqrt(sqrDist);
}
示例3: SlowCoordinate
/// <summary>
/// Creates a SlowCoordinate from any ICoordinate Interface
/// </summary>
/// <param name="coordinate">The Vector.IPoint interface to construct a coordinate from</param>
public SlowCoordinate(Coordinate coordinate)
{
_numOrdinates = coordinate.NumOrdinates;
_values = new double[_numOrdinates];
double[] inVals = coordinate.ToArray();
for (int I = 0; I < _numOrdinates; I++)
{
_values[I] = inVals[I];
}
}