Skip to content

Commit

Permalink
Release v.0.3.
Browse files Browse the repository at this point in the history
Change mathematics library to mathnet-numerics (MIT). All transformation classes rewrite to mathnet-numerics.
Rename all classes with tests.
Add SingularValueDecomposition algorithm calculation parameters transformation.
Add SingularValueDecomposition xml doc.
Coverage 98%.
  • Loading branch information
vangogih committed Apr 25, 2019
1 parent 38fd696 commit 8f22cf2
Show file tree
Hide file tree
Showing 18 changed files with 915 additions and 766 deletions.
3 changes: 2 additions & 1 deletion SCPT/CalculateParameters/Helper/AbstractTransformation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Extreme.Mathematics;
using MathNet.Numerics.LinearAlgebra;
using SCPT.Transformation;

namespace SCPT.Helper
Expand All @@ -17,6 +17,7 @@ namespace SCPT.Helper
/// </code>
/// <seealso cref="NewtonIterationProcess"/>
/// <seealso cref="LinearProcedure"/>
/// <seealso cref="SingularValueDecomposition"/>
/// </example>
/// </summary>
public abstract class AbstractTransformation
Expand Down
36 changes: 22 additions & 14 deletions SCPT/CalculateParameters/Helper/ConvertMatrix.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Extreme.Mathematics;
using MathNet.Numerics.LinearAlgebra;

namespace SCPT.Helper
{
Expand All @@ -11,16 +11,16 @@ public static class ConvertMatrix
{
internal static Vector<double> VectorParametersToDeltaCoordinate(Matrix<double> convertMatrix)
{
var result = Matrix.Create<double>(3, 1);
var result = Vector<double>.Build.Dense(3, 1);
var dx = convertMatrix[0, 0];
var dy = convertMatrix[1, 0];
var dz = convertMatrix[1, 0];

result[0, 0] = dx;
result[1, 0] = dy;
result[2, 0] = dz;
result[0] = dx;
result[1] = dy;
result[2] = dz;

return result.ReshapeAsVector();
return result;
}

internal static Matrix<double> VectorParametersToRotateMatrix(Matrix<double> convertMatrix)
Expand Down Expand Up @@ -65,15 +65,23 @@ public static Matrix<double> Convert_RotMatrixWithM_To_RotMatrixWithoutM(Matrix<
// |-wz*(1+m) 1+m wx*(1+m) | => |-wz 1 wx|
// | wy*(1+m) -wx*(1+m) 1+m | | wy -wx 1|

var onePlusM = convertMatrix[0, 0];
var wx = convertMatrix[1, 2] / onePlusM;
var wy = convertMatrix[2, 0] / onePlusM;
var wz = convertMatrix[0, 1] / onePlusM;

return InitializeRotationMatrix(wx, wy, wz);
try
{
var onePlusM = convertMatrix[0, 0];
var wx = convertMatrix[1, 2] / onePlusM;
var wy = convertMatrix[2, 0] / onePlusM;
var wz = convertMatrix[0, 1] / onePlusM;
return InitializeRotationMatrix(wx, wy, wz);
}
catch (DivideByZeroException e)
{
// |1 0 0|
// |0 1 0|
// |0 0 1|
return Matrix<double>.Build.DenseDiagonal(3, 3, 1);
}
}


private static void CheckCorrectInputMatrix(Matrix<double> matrix)
{
if (matrix == null)
Expand All @@ -89,7 +97,7 @@ private static Matrix<double> InitializeRotationMatrix(double wx, double wy, dou
// |1 wz -wy|
// |-wz 1 wx|
// | wy -wx 1|
var rotationMatrix = Matrix.Create<double>(3, 3);
var rotationMatrix = Matrix<double>.Build.Dense(3, 3);
rotationMatrix[0, 0] = 1;
rotationMatrix[0, 1] = wz;
rotationMatrix[0, 2] = -wy;
Expand Down
6 changes: 1 addition & 5 deletions SCPT/CalculateParameters/Helper/Extension.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System.Collections.Generic;
using Extreme.Mathematics;
using SCPT.Transformation;

namespace SCPT.Helper
{
internal static class Extension
{
// TODO write Helmert transformation
// TODO write Helmert transformation
}
}
15 changes: 9 additions & 6 deletions SCPT/CalculateParameters/SCPT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
<DocumentationFile>bin\Release\SCPT.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Extreme.Numerics, Version=7.0.6.0, Culture=neutral, PublicKeyToken=9e513770f58567b2">
<HintPath>..\packages\Extreme.Numerics.7.0.6\lib\net46\Extreme.Numerics.dll</HintPath>
<Reference Include="MathNet.Numerics, Version=4.7.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\MathNet.Numerics.4.7.0\lib\net40\MathNet.Numerics.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll</HintPath>
Expand All @@ -67,10 +69,11 @@
<Compile Include="Helper\Point.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tests\BaseTest.cs" />
<Compile Include="Tests\ConvertMatrix\ConvertMatrixTests.cs" />
<Compile Include="Tests\LinearProcedure\LinearProcedureTests.cs" />
<Compile Include="Tests\NewtonIterationProcess\NewtonIterarionProcessTests.cs" />
<Compile Include="Tests\NewtonIterationProcess\PointTests.cs" />
<Compile Include="Tests\ConvertMatrix\TestsConvertMatrix.cs" />
<Compile Include="Tests\LinearProcedure\TestsLinearProcedure.cs" />
<Compile Include="Tests\NewtonIterationProcess\TestsNewtonIterarionProcess.cs" />
<Compile Include="Tests\NewtonIterationProcess\TestsPoint.cs" />
<Compile Include="Tests\SingularValueDecomposition\TestsSingularValueDecomposition.cs" />
<Compile Include="Transformation\LinearProcedure.cs" />
<Compile Include="Transformation\NewtonIterationProcess.cs" />
<Compile Include="Transformation\SingularValueDecomposition.cs" />
Expand Down
49 changes: 22 additions & 27 deletions SCPT/CalculateParameters/Tests/BaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
using System;
using System.Collections.Generic;
using System.IO;
using Extreme.Mathematics;
using Extreme.Mathematics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra;
using SCPT.Helper;


internal partial class Incapsulation
public abstract class BaseTest
{
public abstract class BaseTest
{
protected static string PathToTest =
"D:\\RiderProjects\\-SCPT-SystemCoordinateParametersTransformation\\SCPT\\CalculateParameters\\Tests";
protected static string PathToTest =
"D:\\RiderProjects\\-SCPT-SystemCoordinateParametersTransformation\\SCPT\\CalculateParameters\\Tests";

protected DenseMatrix<double> ReadControlDataFromFile(string path, int row, int col)
protected Matrix<double> ReadControlDataFromFile(string path, int row, int col)
{
var matrixFromData = Matrix<double>.Build.Dense(row, col);
var data = File.ReadAllLines(path);
for (int textRow = 0; textRow < data.Length; textRow++)
{
var matrixFromData = Matrix.Create<double>(row, col);
var data = File.ReadAllLines(path);
for (int textRow = 0; textRow < data.Length; textRow++)
{
var split = data[textRow].Split(' ');
for (int textCol = 0; textCol < split.Length; textCol++)
matrixFromData[textRow, textCol] = Convert.ToDouble(split[textCol]);
}

return matrixFromData;
var split = data[textRow].Split(' ');
for (int textCol = 0; textCol < split.Length; textCol++)
matrixFromData[textRow, textCol] = Convert.ToDouble(split[textCol]);
}

protected void FillListsCoordinationData(string path, ref List<Point> listSrc, ref List<Point> listDest)
return matrixFromData;
}

protected void FillListsCoordinationData(string path, ref List<Point> listSrc, ref List<Point> listDest)
{
var srcMatrix = ReadControlDataFromFile(path + "\\testpoints_src.txt", 10, 3);
var dstMatrix = ReadControlDataFromFile(path + "\\testpoints_dest.txt", 10, 3);
for (int row = 0; row < srcMatrix.RowCount; row++)
{
var srcMatrix = ReadControlDataFromFile(path + "\\testpoints_src.txt", 10, 3);
var dstMatrix = ReadControlDataFromFile(path + "\\testpoints_dest.txt", 10, 3);
for (int row = 0; row < srcMatrix.RowCount; row++)
{
listSrc.Add(new Point(srcMatrix[row, 0], srcMatrix[row, 1], srcMatrix[row, 2]));
listDest.Add(new Point(dstMatrix[row, 0], dstMatrix[row, 1], dstMatrix[row, 2]));
}
listSrc.Add(new Point(srcMatrix[row, 0], srcMatrix[row, 1], srcMatrix[row, 2]));
listDest.Add(new Point(dstMatrix[row, 0], dstMatrix[row, 1], dstMatrix[row, 2]));
}
}
}
121 changes: 0 additions & 121 deletions SCPT/CalculateParameters/Tests/ConvertMatrix/ConvertMatrixTests.cs

This file was deleted.

Loading

0 comments on commit 8f22cf2

Please sign in to comment.