Compare commits

..

No commits in common. "2d78cb24814f43fc17754399b9920743907dd5aa" and "29b37d91c161d3aaefccff473ab30eac279106c1" have entirely different histories.

3 changed files with 12 additions and 37 deletions

View File

@ -24,11 +24,15 @@ namespace LinearAlgebra {
horizontal = 0;
vertical = 0;
}
public Direction(Angle horizontal, Angle vertical) {
this.horizontal = horizontal.inDegrees;
this.vertical = vertical.inDegrees;
this.Normalize();
}
// public Direction(Angle horizontal, Angle vertical) {
// this.horizontal = horizontal.inDegrees;
// }
// public Direction(float horizontal, float vertical) {
// this.horizontal = horizontal;
// this.vertical = vertical;
// //Normalize();
// }
public static Direction Degrees(float horizontal, float vertical) {
Direction d = new() {
@ -78,33 +82,6 @@ namespace LinearAlgebra {
Vector3Float v = new(x, y, z);
return v;
}
public static bool operator ==(Direction d1, Direction d2) {
bool horizontalEq = d1.horizontal == d2.horizontal;
bool verticalEq = d1.vertical == d2.vertical;
return horizontalEq && verticalEq;
}
public static bool operator !=(Direction d1, Direction d2) {
bool horizontalNEq = d1.horizontal != d2.horizontal;
bool verticalNEq = d1.vertical != d2.vertical;
return horizontalNEq || verticalNEq;
}
public override bool Equals(object obj) {
if (obj is not Direction d)
return false;
bool horizontalEq = this.horizontal == d.horizontal;
bool verticalEq = this.vertical == d.vertical;
return horizontalEq && verticalEq;
}
public override int GetHashCode() {
return (this.horizontal, this.vertical).GetHashCode();
}
}
}

View File

@ -9,12 +9,10 @@ namespace LinearAlgebra.Test {
[Test]
public void Compare() {
Direction d1 = Direction.Degrees(45, 135);
Direction d2 = new(Angle.Degrees(45), Angle.Degrees(135));
Direction d = Direction.Degrees(45, 135);
bool r;
r = d1 == d2;
r = d == new Direction(Angle.Degrees(45), Angle.Degrees(135));
Assert.True(r);
Assert.AreEqual(d1, d2);
}
};
}

View File

@ -70,7 +70,7 @@ namespace RoboidControl {
touchUpdated = false;
return bytes;
#else
return Array.Empty<byte>();
return 0;
#endif
}