-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust namespaces, added path builder
- Loading branch information
Boris
committed
Aug 2, 2024
1 parent
168d525
commit fc59b9c
Showing
36 changed files
with
477 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Numerics; | ||
|
||
namespace GdsSharp.Lib.Test; | ||
|
||
[TestFixture] | ||
public class VectorExtensionsTests | ||
{ | ||
private const float TwoPi = 2 * MathF.PI; | ||
|
||
[Test] | ||
public void Rotate_Rotate90Degrees_CorrectResult() | ||
{ | ||
var vec = new Vector2(1, 0); | ||
const float radians = MathF.PI / 2; | ||
|
||
var result = vec.Rotate(radians); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(result.X, Is.EqualTo(0).Within(1e-6)); // allowing a small tolerance for floating point errors | ||
Assert.That(result.Y, Is.EqualTo(1).Within(1e-6)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void Rotate_Rotate180Degrees_CorrectResult() | ||
{ | ||
var vec = new Vector2(1, 0); | ||
const float radians = MathF.PI; | ||
|
||
var result = vec.Rotate(radians); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(result.X, Is.EqualTo(-1).Within(1e-6)); | ||
Assert.That(result.Y, Is.EqualTo(0).Within(1e-6)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void Rotate_Rotate360Degrees_CorrectResult() | ||
{ | ||
var vec = new Vector2(1, 0); | ||
const float radians = 2 * MathF.PI; | ||
|
||
var result = vec.Rotate(radians); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(result.X, Is.EqualTo(1).Within(1e-6)); | ||
Assert.That(result.Y, Is.EqualTo(0).Within(1e-6)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void Angle_VectorAt45Degrees_CorrectResult() | ||
{ | ||
var vec = new Vector2(1, 1); | ||
|
||
var result = vec.Angle(); | ||
|
||
Assert.That(result, Is.EqualTo(MathF.PI / 4).Within(1e-6)); | ||
} | ||
|
||
[Test] | ||
public void Angle_VectorAt90Degrees_CorrectResult() | ||
{ | ||
var vec = new Vector2(0, 1); | ||
|
||
var result = vec.Angle(); | ||
|
||
Assert.That(result, Is.EqualTo(MathF.PI / 2).Within(1e-6)); | ||
} | ||
|
||
[Test] | ||
public void Angle_VectorAtNegative45Degrees_CorrectResult() | ||
{ | ||
var vec = new Vector2(1, -1); | ||
|
||
var result = vec.Angle(); | ||
|
||
Assert.That(result, Is.EqualTo(-MathF.PI / 4).Within(1e-6)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.