convert Vector2D into value type

This commit is contained in:
Michael Becker 2021-10-27 07:43:31 -04:00
parent 545b3728f1
commit c09ec3549d
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C

View File

@ -5,28 +5,54 @@ using System.Text;
namespace MBS.Framework.Drawing
{
public abstract class Vector
public struct Vector2D : IEquatable<Vector2D>
{
}
public class Vector2D
{
private double mvarX = 0.0;
public double X { get { return mvarX; } set { mvarX = value; } }
private double mvarY = 0.0;
public double Y { get { return mvarY; } set { mvarY = value; } }
private bool _IsNotEmpty;
public bool IsEmpty { get { return !_IsNotEmpty; } }
public static Vector2D Empty = new Vector2D();
public double X { get; set; }
public double Y { get; set; }
public Vector2D()
{
}
public Vector2D(double x, double y)
{
mvarX = x;
mvarY = y;
X = x;
Y = y;
_IsNotEmpty = true;
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
#region IEquatable implementation
public bool Equals(Vector2D other)
{
return (this.X.Equals(other.X) && this.Y.Equals(other.Y));
}
public static bool operator ==(Vector2D left, Vector2D right)
{
return left.Equals(right);
}
public static bool operator !=(Vector2D left, Vector2D right)
{
return !left.Equals(right);
}
public override bool Equals(object obj)
{
if (obj is Vector2D)
{
Vector2D other = (Vector2D)obj;
return X.Equals(other.X) && Y.Equals(other.Y) && IsEmpty.Equals(other.IsEmpty);
}
return base.Equals(obj);
}
#endregion
}
}