Skip to content

Commit

Permalink
Add comment, condense code
Browse files Browse the repository at this point in the history
  • Loading branch information
practisebody committed May 9, 2019
1 parent b899a15 commit 6296933
Show file tree
Hide file tree
Showing 44 changed files with 343 additions and 315 deletions.
7 changes: 0 additions & 7 deletions Assets/LCY/Math/ILerpable.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Assets/LCY/Math/ILerpable.cs.meta

This file was deleted.

61 changes: 0 additions & 61 deletions Assets/LCY/Math/Stablizer.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Assets/LCY/Math/Stablizer.cs.meta

This file was deleted.

57 changes: 35 additions & 22 deletions Assets/LCY/Math/Utilities.cs
Expand Up @@ -6,20 +6,33 @@

namespace LCY
{
/// <summary>
/// Math utility functions
/// </summary>
public static partial class Utilities
{
/// <summary>
/// Converts a Rodrigues as Vector3 to Quaternion.
/// See https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula.
/// </summary>
public static Quaternion Rodrigues2Quaternion(Vector3 rotation)
{
float theta = Mathf.Rad2Deg * rotation.magnitude;
Vector3 axis = rotation.normalized;
return Quaternion.AngleAxis(theta, axis);
}

/// <summary>
/// Converts a List of 3 double to a Vector3
/// </summary>
public static Vector3 List2Vector3(List<double> vec)
{
return new Vector3((float)(vec[0]), (float)(vec[1]), (float)(vec[2]));
}

/// <summary>
/// Converts a Rodrigues as a List of 3 doubles to a Quaternion
/// </summary>
public static Quaternion Rodrigues2Quaternion(List<double> rvec)
{
Vector3 axis = List2Vector3(rvec);
Expand All @@ -28,28 +41,28 @@ public static Quaternion Rodrigues2Quaternion(List<double> rvec)
return Quaternion.AngleAxis(theta, axis);
}

[DllImport("HoloOpenCVHelper")]
public static extern void addLine(float x, float y, float z, float dx, float dy, float dz);
[DllImport("HoloOpenCVHelper")]
public static extern void solveLineAndClear();
[DllImport("HoloOpenCVHelper")]
public static extern float getLinesIntersectionX();
[DllImport("HoloOpenCVHelper")]
public static extern float getLinesIntersectionY();
[DllImport("HoloOpenCVHelper")]
public static extern float getLinesIntersectionZ();
//[DllImport("HoloOpenCVHelper")]
//public static extern void addLine(float x, float y, float z, float dx, float dy, float dz);
//[DllImport("HoloOpenCVHelper")]
//public static extern void solveLineAndClear();
//[DllImport("HoloOpenCVHelper")]
//public static extern float getLinesIntersectionX();
//[DllImport("HoloOpenCVHelper")]
//public static extern float getLinesIntersectionY();
//[DllImport("HoloOpenCVHelper")]
//public static extern float getLinesIntersectionZ();

public static Vector3 LinesIntersection(List<Tuple<Vector3, Vector3>> lines)
{
foreach (Tuple<Vector3, Vector3> line in lines)
{
addLine(line.Item1.x, line.Item1.y, line.Item1.z, line.Item2.x, line.Item2.y, line.Item2.z);
}
solveLineAndClear();
float x = getLinesIntersectionX();
float y = getLinesIntersectionY();
float z = getLinesIntersectionZ();
return new Vector3(x, y, z);
}
//public static Vector3 LinesIntersection(List<Tuple<Vector3, Vector3>> lines)
//{
// foreach (Tuple<Vector3, Vector3> line in lines)
// {
// addLine(line.Item1.x, line.Item1.y, line.Item1.z, line.Item2.x, line.Item2.y, line.Item2.z);
// }
// solveLineAndClear();
// float x = getLinesIntersectionX();
// float y = getLinesIntersectionY();
// float z = getLinesIntersectionZ();
// return new Vector3(x, y, z);
//}
}
}
3 changes: 3 additions & 0 deletions Assets/LCY/Singleton.cs
Expand Up @@ -4,6 +4,9 @@

namespace LCY
{
/// <summary>
/// Singleton generic class, instantiate once
/// </summary>
public class Singleton<T> where T : Singleton<T>, new()
{
public static T Instance { get; } = new T();
Expand Down

0 comments on commit 6296933

Please sign in to comment.