Skip to content

Commit

Permalink
Merge pull request #53 from do-i-know-it/fix/1.0.2
Browse files Browse the repository at this point in the history
Release version 1.0.2
  • Loading branch information
do-i-know-it committed Nov 5, 2021
2 parents be72ce9 + b3cbefb commit b581fab
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 38 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Release notes for version 1.0.1
# Release notes for version 1.0.2

- Fixed implementations of signals for 3D space.
- Fixed document comments for framework.
67 changes: 53 additions & 14 deletions Signals/Space3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace YggdrAshill.Nuadha.Signals
/// </summary>
public static class Space3D
{
private const float Tolerance = float.Epsilon;
private const float Tolerance = 1e-5f;

private const float Length = 1.0f;

#region Position
Expand Down Expand Up @@ -317,6 +318,11 @@ public struct Direction :
/// </summary>
public const float Maximum = Length;

/// <summary>
/// <see cref="Tolerance"/> for <see cref="Direction"/>.
/// </summary>
public static float Tolerance { get; } = Space3D.Tolerance;

/// <summary>
/// <see cref="Right"/> in the coordinate.
/// </summary>
Expand Down Expand Up @@ -434,14 +440,17 @@ public Direction Reversed
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="frontal"/> is <see cref="float.NaN"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="horizontal"/> out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="horizontal"/> is out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="vertical"/> out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="vertical"/> is out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="frontal"/> out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="frontal"/> is out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="horizontal"/>^2 + <paramref name="vertical"/>^2 + <paramref name="frontal"/>^2 is larger than <see cref="Tolerance"/>.
/// </exception>
public Direction(float horizontal, float vertical, float frontal)
{
Expand Down Expand Up @@ -479,7 +488,7 @@ var dotted

if (difference > Tolerance)
{
throw new ArgumentOutOfRangeException($"{nameof(horizontal)}^2 + {nameof(vertical)}^2 + {nameof(frontal)}^2");
throw new ArgumentOutOfRangeException($"{nameof(horizontal)}^2 + {nameof(vertical)}^2 + {nameof(frontal)}^2 > {Tolerance}");
}

this.horizontal = horizontal;
Expand Down Expand Up @@ -648,6 +657,21 @@ public struct Rotation :
ISignal,
IEquatable<Rotation>
{
/// <summary>
/// <see cref="Minimum"/> of <see cref="Horizontal"/> and <see cref="Vertical"/> and <see cref="Frontal"/> and <see cref="Real"/>.
/// </summary>
public const float Minimum = -Length;

/// <summary>
/// <see cref="Maximum"/> of <see cref="Horizontal"/> and <see cref="Vertical"/> and <see cref="Frontal"/> and <see cref="Real"/>.
/// </summary>
public const float Maximum = Length;

/// <summary>
/// <see cref="Tolerance"/> for <see cref="Rotation"/>.
/// </summary>
public static float Tolerance { get; } = Space3D.Tolerance;

/// <summary>
/// <see cref="Rotation"/> not rotated.
/// </summary>
Expand Down Expand Up @@ -755,6 +779,21 @@ private void InitializeIfNeeded()
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="real"/> is <see cref="float.NaN"/>.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="horizontal"/> is out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="vertical"/> is out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="frontal"/> is out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="real"/> is out of range between <see cref="Minimum"/> and <see cref="Maximum"/>.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if <paramref name="horizontal"/>^2 + <paramref name="vertical"/>^2 + <paramref name="frontal"/>^2 + <paramref name="real"/>^2 is larger than <see cref="Tolerance"/>.
/// </exception>
public Rotation(float horizontal, float vertical, float frontal, float real)
{
if (float.IsNaN(horizontal))
Expand All @@ -774,21 +813,21 @@ public Rotation(float horizontal, float vertical, float frontal, float real)
throw new ArgumentException($"{nameof(real)} is NaN.");
}

if (horizontal < -Length || Length < horizontal)
if (horizontal < Minimum || Maximum < horizontal)
{
throw new ArgumentOutOfRangeException(nameof(horizontal));
}
if (vertical < -Length || Length < vertical)
if (vertical < Minimum || Maximum < vertical)
{
throw new ArgumentOutOfRangeException(nameof(vertical));
}
if (frontal < -Length || Length < frontal)
if (frontal < Minimum || Maximum < frontal)
{
throw new ArgumentOutOfRangeException(nameof(frontal));
}
if (real < -Length || Length < real)
if (real < Minimum || Maximum < real)
{
throw new ArgumentOutOfRangeException(nameof(frontal));
throw new ArgumentOutOfRangeException(nameof(real));
}

var dotted
Expand All @@ -800,7 +839,7 @@ var dotted

if (difference > Tolerance)
{
throw new ArgumentOutOfRangeException($"{nameof(horizontal)}^2 + {nameof(vertical)}^2 + {nameof(frontal)}^2 + {nameof(real)}^2");
throw new ArgumentOutOfRangeException($"{nameof(horizontal)}^2 + {nameof(vertical)}^2 + {nameof(frontal)}^2 + {nameof(real)}^2 > {Tolerance}");
}

this.horizontal = horizontal;
Expand Down
Loading

0 comments on commit b581fab

Please sign in to comment.