Skip to content

Commit

Permalink
Cleanup Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
JensKrumsieck committed Sep 5, 2022
1 parent a613640 commit a7ab3fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 83 deletions.
64 changes: 16 additions & 48 deletions ChemSharp/Mathematics/FractionalCoordinates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ public static class FractionalCoordinates
/// <param name="fractional"></param>
/// <param name="conversionMatrix">a 3x3 conversion matrix</param>
/// <returns></returns>
public static Vector3 FractionalToCartesian(Vector3 fractional, Vector3[] conversionMatrix)
{
var vector = new float[3];
for (var i = 0; i <= 2; i++)
vector[i] = fractional.X * conversionMatrix[i].X + fractional.Y * conversionMatrix[i].Y +
fractional.Z * conversionMatrix[i].Z;

return new Vector3(vector[0], vector[1], vector[2]);
}

public static Vector3 FractionalToCartesian(Vector3 fractional, Matrix4x4 matrix) =>
Vector3.TransformNormal(fractional, matrix);

Expand All @@ -39,44 +29,22 @@ public static Vector3 FractionalToCartesian(Vector3 fractional, Matrix4x4 matrix
/// <param name="beta"></param>
/// <param name="gamma"></param>
/// <returns></returns>
// public static Vector3[] ConversionMatrix(float a, float b, float c, float alpha, float beta, float gamma)
// {
// var line1 = new Vector3(a, b * MathF.Cos(gamma * MathF.PI / 180f), c * MathF.Cos(beta * MathF.PI / 180f));
// var line2 = new Vector3(
// 0,
// b * MathF.Sin(gamma * MathF.PI / 180f),
// c * (MathF.Cos(alpha * MathF.PI / 180f) -
// MathF.Cos(beta * MathF.PI / 180f) * MathF.Cos(gamma * MathF.PI / 180f)) /
// MathF.Sin(gamma * MathF.PI / 180f));
//
// var line3 = new Vector3(
// 0,
// 0,
// c * MathF.Sqrt(1f - MathF.Pow(MathF.Cos(alpha * MathF.PI / 180f), 2f) -
// MathF.Pow(MathF.Cos(beta * MathF.PI / 180f), 2f) -
// MathF.Pow(MathF.Cos(gamma * MathF.PI / 180f), 2f) + 2f *
// MathF.Cos(alpha * MathF.PI / 180f) *
// MathF.Cos(beta * MathF.PI / 180f) *
// MathF.Cos(gamma * MathF.PI / 180f)) /
// MathF.Sin(gamma * MathF.PI / 180f));
// return new[] {line1, line2, line3};
// }
public static Matrix4x4 ConversionMatrix(float a, float b, float c, float alpha, float beta, float gamma)
=> Matrix4x4.Transpose(new Matrix4x4(
a, b * MathF.Cos(gamma * MathF.PI / 180f),
c * MathF.Cos(beta * MathF.PI / 180f), 0,
0, b * MathF.Sin(gamma * MathF.PI / 180f), c *
(MathF.Cos(alpha * MathF.PI / 180f) -
MathF.Cos(beta * MathF.PI / 180f) *
MathF.Cos(gamma * MathF.PI / 180f)) /
MathF.Sin(gamma * MathF.PI / 180f), 0,
0, 0,
c * MathF.Sqrt(1f - MathF.Pow(MathF.Cos(alpha * MathF.PI / 180f), 2f) -
MathF.Pow(MathF.Cos(beta * MathF.PI / 180f), 2f) -
MathF.Pow(MathF.Cos(gamma * MathF.PI / 180f), 2f) + 2f *
MathF.Cos(alpha * MathF.PI / 180f) *
MathF.Cos(beta * MathF.PI / 180f) *
MathF.Cos(gamma * MathF.PI / 180f)) /
MathF.Sin(gamma * MathF.PI / 180f), 0,
0, 0, 0, 1));
a, b * MathF.Cos(gamma * MathF.PI / 180f),
c * MathF.Cos(beta * MathF.PI / 180f), 0,
0, b * MathF.Sin(gamma * MathF.PI / 180f), c *
(MathF.Cos(alpha * MathF.PI / 180f) -
MathF.Cos(beta * MathF.PI / 180f) *
MathF.Cos(gamma * MathF.PI / 180f)) /
MathF.Sin(gamma * MathF.PI / 180f), 0,
0, 0,
c * MathF.Sqrt(1f - MathF.Pow(MathF.Cos(alpha * MathF.PI / 180f), 2f) -
MathF.Pow(MathF.Cos(beta * MathF.PI / 180f), 2f) -
MathF.Pow(MathF.Cos(gamma * MathF.PI / 180f), 2f) + 2f *
MathF.Cos(alpha * MathF.PI / 180f) *
MathF.Cos(beta * MathF.PI / 180f) *
MathF.Cos(gamma * MathF.PI / 180f)) /
MathF.Sin(gamma * MathF.PI / 180f), 0,
0, 0, 0, 1));
}
35 changes: 0 additions & 35 deletions ChemSharp/Mathematics/VectorMath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,6 @@ public static Vector3 Sum(this IEnumerable<Vector3> input)
return new Vector3(sumX, sumY, sumZ);
}

/// <summary>
/// Wrapper function for <see cref="Vector3.Dot" />
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
[Obsolete("Use Vector3.Dot instead!")]
public static float Dot(Vector3 left, Vector3 right) => Vector3.Dot(left, right);

/// <summary>
/// Wrapper function for <see cref="Vector3.Cross" />
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
[Obsolete("Use Vector3.Cross instead!")]
public static Vector3 Cross(Vector3 left, Vector3 right) => Vector3.Cross(left, right);

/// <summary>
/// Wrapper function for <see cref="Vector3.Normalize" />
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
[Obsolete("Use Vector3.Normalize instead!")]
public static Vector3 Normalize(Vector3 v) => Vector3.Normalize(v);

/// <summary>
/// Wrapper function for <see cref="Vector3.Distance" />
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
[Obsolete("Use Vector3.Distance instead!")]
public static float Distance(Vector3 left, Vector3 right) => Vector3.Distance(left, right);

/// <summary>
/// Projects a point onto plane p
/// </summary>
Expand Down

0 comments on commit a7ab3fe

Please sign in to comment.