mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-09 23:35:41 +00:00
Implement ToString for Rotation
This commit is contained in:
parent
6804959f93
commit
ca0769faeb
@ -1,4 +1,6 @@
|
||||
using System.Numerics;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using Cysharp.Text;
|
||||
using X10D.Math;
|
||||
using X10D.Numerics;
|
||||
|
||||
@ -7,7 +9,7 @@ namespace VpSharp;
|
||||
/// <summary>
|
||||
/// Represents a rotation.
|
||||
/// </summary>
|
||||
public readonly struct Rotation : IEquatable<Rotation>
|
||||
public readonly struct Rotation : IEquatable<Rotation>, IFormattable
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents no rotation.
|
||||
@ -169,4 +171,38 @@ public readonly struct Rotation : IEquatable<Rotation>
|
||||
{
|
||||
return HashCode.Combine(Angle, Roll, Tilt, Yaw);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string representation of these coordinates.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="string" /> representation of these coordinates.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString("{0}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string representation of these coordinates.
|
||||
/// </summary>
|
||||
/// <param name="format">The format to apply to each component.</param>
|
||||
/// <param name="formatProvider">The format provider.</param>
|
||||
/// <returns>A <see cref="string" /> representation of these coordinates.</returns>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider = null)
|
||||
{
|
||||
format ??= "{0}";
|
||||
string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
|
||||
using var builder = ZString.CreateUtf8StringBuilder();
|
||||
builder.Append('<');
|
||||
builder.Append(string.Format(formatProvider, format, Tilt));
|
||||
builder.Append(separator);
|
||||
builder.Append(' ');
|
||||
builder.Append(string.Format(formatProvider, format, Yaw));
|
||||
builder.Append(separator);
|
||||
builder.Append(' ');
|
||||
builder.Append(string.Format(formatProvider, format, Roll));
|
||||
builder.Append('>');
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user