コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rectanglei"/> 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 Rectanglei(Point2i location, Size2i size)
 {
     X      = location.X;
     Y      = location.Y;
     Width  = size.Width;
     Height = size.Height;
 }
コード例 #2
0
ファイル: Circlei.cs プロジェクト: bonomali/Ibasa
 /// <summary>
 /// Initializes a new instance of the <see cref="Circlei"/> 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 Circlei(Point2i center, int radius)
 {
     Contract.Requires(0 <= radius);
     X      = center.X;
     Y      = center.Y;
     Radius = radius;
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Ellipsei"/> 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 Ellipsei(Point2i center, Size2i size)
 {
     X      = center.X;
     Y      = center.Y;
     Width  = size.Width;
     Height = size.Height;
 }
コード例 #4
0
		public Point2i[] ToArray()
		{
			var result = new Point2i[Count];
			for (int i=0; i<Count; ++i)
			{
				result[i] = this[i];
			}
			return result;
		}
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Ellipsei"/> 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 Ellipsei(Point2i center, int width, int height)
 {
     Contract.Requires(0 <= width);
     Contract.Requires(0 <= height);
     X      = center.X;
     Y      = center.Y;
     Width  = width;
     Height = height;
 }
コード例 #6
0
		/// <summary>
		/// Reads a <see cref="Polygon2i"/> from an <see cref="Ibasa.IO.BinaryReader">.
		/// </summary>
		public static Polygon2i ReadPolygon2i(this Ibasa.IO.BinaryReader reader)
		{
			var length = reader.ReadInt32();
			var array = new Point2i[length];
			for (int i=0; i<length; ++i)
			{
				array[i] = reader.ReadPoint2i();
			}
			return new Polygon2i(array);
		}
コード例 #7
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
        /// <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(Point2i 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)));
        }
コード例 #8
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Clamp(Point2i value, Point2i min, Point2i max)
 {
     return(new Point2i(Functions.Clamp(value.X, min.X, max.X), Functions.Clamp(value.Y, min.Y, max.Y)));
 }
コード例 #9
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Max(Point2i value1, Point2i value2)
 {
     return(new Point2i(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y)));
 }
コード例 #10
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Abs(Point2i value)
 {
     return(new Point2i(Functions.Abs(value.X), Functions.Abs(value.Y)));
 }
コード例 #11
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Modulate(Point2i left, Point2i right)
 {
     return(new Point2i(left.X * right.X, left.Y * right.Y));
 }
コード例 #12
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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(Point2i value, Func <int, int> mapping)
 {
     return(new Point2i(mapping(value.X), mapping(value.Y)));
 }
コード例 #13
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Divide(Point2i point, int scalar)
 {
     return(new Point2i(point.X / scalar, point.Y / scalar));
 }
コード例 #14
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Add(Point2i point, Vector2i vector)
 {
     return(new Point2i(point.X + vector.X, point.Y + vector.Y));
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Line2i"/> using the specified values.
 /// </summary>
 /// <param name="start">Start point of the line.</param>
 /// <param name="end">End point of the line.</param>
 public Line2i(Point2i start, Point2i end)
 {
     Start = start;
     End   = end;
 }
コード例 #16
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Subtract(Point2i point, Vector2i vector)
 {
     return(new Point2i(point.X - vector.X, point.Y - vector.Y));
 }
コード例 #17
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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(Point2i value)
 {
     return(value.X != 0 && value.Y != 0);
 }
コード例 #18
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 int ManhattenDistance(Point2i value1, Point2i value2)
 {
     return(Functions.Abs(value2.X - value1.X) + Functions.Abs(value2.Y - value1.Y));
 }
コード例 #19
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 int DistanceSquared(Point2i value1, Point2i value2)
 {
     return(Vector.AbsoluteSquared(value2 - value1));
 }
コード例 #20
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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(Point2i value1, Point2i value2)
 {
     return(Vector.Absolute(value2 - value1));
 }
コード例 #21
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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(Point2i left, Point2i right)
 {
     return(left == right);
 }
コード例 #22
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Vector2i Subtract(Point2i left, Point2i right)
 {
     return(new Vector2i(left.X - right.X, left.Y - right.Y));
 }
コード例 #23
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 int Project(Point2i point, Vector2i vector)
 {
     return(vector.X * point.X + vector.Y * point.Y);
 }
コード例 #24
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2l Map(Point2i value, Func <int, long> mapping)
 {
     return(new Point2l(mapping(value.X), mapping(value.Y)));
 }
コード例 #25
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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(Point2i value)
 {
     return(value.X != 0 || value.Y != 0);
 }
コード例 #26
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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 Point2i Multiply(Point2i point, int scalar)
 {
     return(new Point2i(point.X * scalar, point.Y * scalar));
 }
コード例 #27
0
 public static bool Contains(Rectanglei rectangle, Point2i point)
 {
     return((rectangle.Left <= point.X) && (rectangle.Right >= point.X) &&
            (rectangle.Bottom <= point.Y) && (rectangle.Top >= point.Y));
 }
コード例 #28
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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(Point2i value, Predicate <int> predicate)
 {
     return(predicate(value.X) || predicate(value.Y));
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Line2i"/> 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 Line2i(int startX, int startY, int endX, int endY)
 {
     Start = new Point2i(startX, startY);
     End   = new Point2i(endX, endY);
 }
コード例 #30
0
ファイル: Point2i.cs プロジェクト: bonomali/Ibasa
 /// <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(Point2i value, Func <int, double> mapping)
 {
     return(new Point2d(mapping(value.X), mapping(value.Y)));
 }