Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
override ToString in Matrix3x4
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Feb 25, 2018
1 parent e692c03 commit 8142897
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Bindings/Portable/External/MathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public static float Lerp(float lhs, float rhs, float t)
return lhs * (1.0f - t) + rhs * t;
}

public static string ToFixedSizeString(float number, int cellSize, int precision)
public static string ToFixedSizeString(this float number, int cellSize, int precision)
{
// Similiar to "G{cellSize}" format but without exponential format
var value = number.ToString($"F{precision}");
Expand Down
8 changes: 8 additions & 0 deletions Bindings/Portable/Structs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,14 @@ public Matrix3x4 Inverse()
left.M41 * rhs.m03 + left.M42 * rhs.m13 + left.M43 * rhs.m23 + left.M44
);
}

public override string ToString()
{
const int cellSize = 6, prec = 2;
return $"| {m00.ToFixedSizeString(cellSize, prec)} | {m01.ToFixedSizeString(cellSize, prec)} | {m02.ToFixedSizeString(cellSize, prec)} | {m03.ToFixedSizeString(cellSize, prec)} |\n" +
$"| {m10.ToFixedSizeString(cellSize, prec)} | {m11.ToFixedSizeString(cellSize, prec)} | {m12.ToFixedSizeString(cellSize, prec)} | {m13.ToFixedSizeString(cellSize, prec)} |\n" +
$"| {m20.ToFixedSizeString(cellSize, prec)} | {m21.ToFixedSizeString(cellSize, prec)} | {m22.ToFixedSizeString(cellSize, prec)} | {m23.ToFixedSizeString(cellSize, prec)} |";
}
}

[StructLayout (LayoutKind.Sequential)]
Expand Down

0 comments on commit 8142897

Please sign in to comment.