// ----------------------------------------------------------------------- // // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex { using System.Globalization; /// /// Defines a vector. /// public struct Vector { /// /// The X vector. /// private double x; /// /// The Y vector. /// private double y; /// /// Initializes a new instance of the structure. /// /// The X vector. /// The Y vector. public Vector(double x, double y) { this.x = x; this.y = y; } /// /// Gets the X vector. /// public double X { get { return this.x; } } /// /// Gets the Y vector. /// public double Y { get { return this.y; } } public static Vector operator +(Vector a, Vector b) { return new Vector(a.x + b.x, a.y + b.y); } public static Vector operator -(Vector a, Vector b) { return new Vector(a.x - b.x, a.y - b.y); } /// /// Returns the string representation of the point. /// /// The string representation of the point. public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.x, this.y); } } }