32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
namespace Passer.LinearAlgebra {
|
|
|
|
public class Direction {
|
|
public float horizontal;
|
|
public float vertical;
|
|
|
|
public Direction() {
|
|
horizontal = 0;
|
|
vertical = 0;
|
|
}
|
|
public Direction(float horizontal, float vertical) {
|
|
this.horizontal = horizontal;
|
|
this.vertical = vertical;
|
|
//Normalize();
|
|
}
|
|
|
|
public readonly static Direction forward = new Direction(0, 0);
|
|
public readonly static Direction backward = new Direction(-180, 0);
|
|
public readonly static Direction up = new Direction(0, 90);
|
|
public readonly static Direction down = new Direction(0, -90);
|
|
public readonly static Direction left = new Direction(-90, 0);
|
|
public readonly static Direction right = new Direction(90, 0);
|
|
|
|
public void Normalize() {
|
|
if (this.vertical > 90 || this.vertical < -90) {
|
|
this.horizontal += 180;
|
|
this.vertical = 180 - this.vertical;
|
|
}
|
|
}
|
|
}
|
|
|
|
} |