/// <summary> /// Initializes a new instance of the <see cref="Ellipsel"/> using the specified location and radius. /// </summary> /// <param name="center">The center of the ellipse.</param> /// <param name="size">The size of the ellipse.</param> public Ellipsel(Point2l center, Size2l size) { X = center.X; Y = center.Y; Width = size.Width; Height = size.Height; }
/// <summary> /// Initializes a new instance of the <see cref="Circlel"/> using the specified location and radius. /// </summary> /// <param name="center">The center of the circle.</param> /// <param name="radius">The radius of the circle.</param> public Circlel(Point2l center, long radius) { Contract.Requires(0 <= radius); X = center.X; Y = center.Y; Radius = radius; }
/// <summary> /// Initializes a new instance of the <see cref="Rectanglel"/> using the specified location and size. /// </summary> /// <param name="location">The lower-left corner of the rectangle.</param> /// <param name="size">The size of the rectangle.</param> public Rectanglel(Point2l location, Size2l size) { X = location.X; Y = location.Y; Width = size.Width; Height = size.Height; }
/// <summary> /// Initializes a new instance of the <see cref="Ellipsel"/> using the specified location and radius. /// </summary> /// <param name="center">The center of the ellipse.</param> /// <param name="width">The width of the ellipse.</param> /// <param name="height">The height of the ellipse.</param> public Ellipsel(Point2l center, long width, long height) { Contract.Requires(0 <= width); Contract.Requires(0 <= height); X = center.X; Y = center.Y; Width = width; Height = height; }
public Point2l[] ToArray() { var result = new Point2l[Count]; for (int i = 0; i < Count; ++i) { result[i] = this[i]; } return(result); }
/// <summary> /// Reads a <see cref="Polygon2l"/> from an <see cref="Ibasa.IO.BinaryReader">. /// </summary> public static Polygon2l ReadPolygon2l(this Ibasa.IO.BinaryReader reader) { var length = reader.ReadInt32(); var array = new Point2l[length]; for (int i = 0; i < length; ++i) { array[i] = reader.ReadPoint2l(); } return(new Polygon2l(array)); }
/// <summary> /// Transforms a point in cartesian coordinates to polar coordinates. /// </summary> /// <param name="value">The point to transform.</param> /// <returns>The polar coordinates of value.</returns> public static PolarCoordinate CartesianToPolar(Point2l value) { double theta = Functions.Atan2(value.Y, value.X); if (theta < 0) { theta += 2 * Constants.Pi; } return(new PolarCoordinate( theta, (double)Functions.Sqrt(value.X * value.X + value.Y * value.Y))); }
/// <summary> /// Initializes a new instance of the <see cref="Line2l"/> using the specified values. /// </summary> /// <param name="start">Start point of the line.</param> /// <param name="end">End point of the line.</param> public Line2l(Point2l start, Point2l end) { Start = start; End = end; }
/// <summary> /// Returns a point that contains the highest value from each pair of components. /// </summary> /// <param name="value1">The first point.</param> /// <param name="value2">The second point.</param> /// <returns>The highest of each component in left and the matching component in right.</returns> public static Point2l Max(Point2l value1, Point2l value2) { return(new Point2l(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y))); }
/// <summary> /// Multiplys the components of two points and returns the result. /// </summary> /// <param name="left">The first point to modulate.</param> /// <param name="right">The second point to modulate.</param> /// <returns>The result of multiplying each component of left by the matching component in right.</returns> public static Point2l Modulate(Point2l left, Point2l right) { return(new Point2l(left.X * right.X, left.Y * right.Y)); }
/// <summary> /// Maps the components of a point and returns the result. /// </summary> /// <param name="value">The point to map.</param> /// <param name="mapping">A mapping function to apply to each component.</param> /// <returns>The result of mapping each component of value.</returns> public static Point2f Map(Point2l value, Func <long, float> mapping) { return(new Point2f(mapping(value.X), mapping(value.Y))); }
/// <summary> /// Returns the product of a point and scalar. /// </summary> /// <param name="point">The point to multiply.</param> /// <param name="scalar">The scalar to multiply.</param> /// <returns>The product of the left and right parameters.</returns> public static Point2l Multiply(Point2l point, long scalar) { return(new Point2l(point.X * scalar, point.Y * scalar)); }
/// <summary> /// Subtracts a vector from a point and returns the result. /// </summary> /// <param name="point">The point value to subtract from (the minuend).</param> /// <param name="vector">The vector value to subtract (the subtrahend).</param> /// <returns>The result of subtracting vector from point (the difference).</returns> public static Point2l Subtract(Point2l point, Vector2l vector) { return(new Point2l(point.X - vector.X, point.Y - vector.Y)); }
/// <summary> /// Subtracts one points from another and returns the result. /// </summary> /// <param name="left">The value to subtract from (the minuend).</param> /// <param name="right">The value to subtract (the subtrahend).</param> /// <returns>The result of subtracting right from left (the difference).</returns> public static Vector2l Subtract(Point2l left, Point2l right) { return(new Vector2l(left.X - right.X, left.Y - right.Y)); }
/// <summary> /// Adds a point and a vector and returns the result. /// </summary> /// <param name="point">The point value to add.</param> /// <param name="vector">The vector value to add.</param> /// <returns>The sum of left and right.</returns> public static Point2l Add(Point2l point, Vector2l vector) { return(new Point2l(point.X + vector.X, point.Y + vector.Y)); }
/// <summary> /// Determines whether any components of a point satisfy a condition. /// </summary> /// <param name="value">A point.</param> /// <param name="predicate">A function to test each component for a condition.</param> /// <returns>true if any component of the point passes the test in the specified /// predicate; otherwise, false.</returns> public static bool Any(Point2l value, Predicate <long> predicate) { return(predicate(value.X) || predicate(value.Y)); }
/// <summary> /// Maps the components of a point and returns the result. /// </summary> /// <param name="value">The point to map.</param> /// <param name="mapping">A mapping function to apply to each component.</param> /// <returns>The result of mapping each component of value.</returns> public static Point2d Map(Point2l value, Func <long, double> mapping) { return(new Point2d(mapping(value.X), mapping(value.Y))); }
/// <summary> /// Divides a point by a scalar and returns the result. /// </summary> /// <param name="point">The point to be divided (the dividend).</param> /// <param name="scalar">The scalar to divide by (the divisor).</param> /// <returns>The result of dividing left by right (the quotient).</returns> public static Point2l Divide(Point2l point, long scalar) { return(new Point2l(point.X / scalar, point.Y / scalar)); }
/// <summary> /// Maps the components of a point and returns the result. /// </summary> /// <param name="value">The point to map.</param> /// <param name="mapping">A mapping function to apply to each component.</param> /// <returns>The result of mapping each component of value.</returns> public static Point2i Map(Point2l value, Func <long, int> mapping) { return(new Point2i(mapping(value.X), mapping(value.Y))); }
/// <summary> /// Returns a value that indicates whether two points are equal. /// </summary> /// <param name="left">The first point to compare.</param> /// <param name="right">The second point to compare.</param> /// <returns>true if the left and right are equal; otherwise, false.</returns> public static bool Equals(Point2l left, Point2l right) { return(left == right); }
/// <summary> /// Returns the absolute value (per component). /// </summary> /// <param name="value">A point.</param> /// <returns>The absolute value (per component) of value.</returns> public static Point2l Abs(Point2l value) { return(new Point2l(Functions.Abs(value.X), Functions.Abs(value.Y))); }
/// <summary> /// Returns the distance between two points. /// </summary> /// <param name="value1">The first point.</param> /// <param name="value2">The second point.</param> /// <returns>The distance between value1 and value2.</returns> public static double Distance(Point2l value1, Point2l value2) { return(Vector.Absolute(value2 - value1)); }
/// <summary> /// Constrains each component to a given range. /// </summary> /// <param name="value">A point to constrain.</param> /// <param name="min">The minimum values for each component.</param> /// <param name="max">The maximum values for each component.</param> /// <returns>A point with each component constrained to the given range.</returns> public static Point2l Clamp(Point2l value, Point2l min, Point2l max) { return(new Point2l(Functions.Clamp(value.X, min.X, max.X), Functions.Clamp(value.Y, min.Y, max.Y))); }
/// <summary> /// Returns the squared distance between two points. /// </summary> /// <param name="value1">The first point.</param> /// <param name="value2">The second point.</param> /// <returns>The squared distance between value1 and value2.</returns> public static long DistanceSquared(Point2l value1, Point2l value2) { return(Vector.AbsoluteSquared(value2 - value1)); }
/// <summary> /// Projects a point onto a vector, returns the distance of the projection from the origin. /// </summary> /// <param name="vector">The vector to project onto.</param> /// <param name="point">The point to project.</param> /// <returns>The distance from the origin of the projection.</returns> public static long Project(Point2l point, Vector2l vector) { return(vector.X * point.X + vector.Y * point.Y); }
/// <summary> /// Returns the manhatten distance between two points. /// </summary> /// <param name="value1">The first point.</param> /// <param name="value2">The second point.</param> /// <returns>The manhatten distance between value1 and value2.</returns> public static long ManhattenDistance(Point2l value1, Point2l value2) { return(Functions.Abs(value2.X - value1.X) + Functions.Abs(value2.Y - value1.Y)); }
/// <summary> /// Initializes a new instance of the <see cref="Line2l"/> using the specified values. /// </summary> /// <param name="startX">X coordinate of the start point of the line.</param> /// <param name="startY">Y coordinate of the start point of the line.</param> /// <param name="endX">X coordinate of the end point of the line.</param> /// <param name="endY">Y coordinate of the end point of the line.</param> public Line2l(long startX, long startY, long endX, long endY) { Start = new Point2l(startX, startY); End = new Point2l(endX, endY); }
/// <summary> /// Determines whether all components of a point are non-zero. /// </summary> /// <param name="value">A point.</param> /// <returns>true if all components are non-zero; false otherwise.</returns> public static bool All(Point2l value) { return(value.X != 0 && value.Y != 0); }
public static bool Contains(Rectanglel rectangle, Point2l point) { return((rectangle.Left <= point.X) && (rectangle.Right >= point.X) && (rectangle.Bottom <= point.Y) && (rectangle.Top >= point.Y)); }
/// <summary> /// Determines whether any component of a point is non-zero. /// </summary> /// <param name="value">A point.</param> /// <returns>true if any components are non-zero; false otherwise.</returns> public static bool Any(Point2l value) { return(value.X != 0 || value.Y != 0); }