CodeWalker/Utils/Vectors.cs
2017-09-21 20:33:05 +10:00

60 lines
1.2 KiB
C#

using SharpDX;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CodeWalker
{
public static class Vectors
{
public static Vector3 XYZ(this Vector4 v)
{
return new Vector3(v.X, v.Y, v.Z);
}
public static Vector4 Floor(this Vector4 v)
{
return new Vector4((float)Math.Floor(v.X), (float)Math.Floor(v.Y), (float)Math.Floor(v.Z), (float)Math.Floor(v.W));
}
}
public struct Vector2I
{
public int X;
public int Y;
public Vector2I(int x, int y)
{
X = x;
Y = y;
}
public Vector2I(Vector2 v)
{
X = (int)Math.Floor(v.X);
Y = (int)Math.Floor(v.Y);
}
public override string ToString()
{
return X.ToString() + ", " + Y.ToString();
}
public static Vector2I operator +(Vector2I a, Vector2I b)
{
return new Vector2I(a.X + b.X, a.Y + b.Y);
}
public static Vector2I operator -(Vector2I a, Vector2I b)
{
return new Vector2I(a.X - b.X, a.Y - b.Y);
}
}
}