示例#1
0
 /// <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;
 }
示例#2
0
文件: Circlel.cs 项目: bonomali/Ibasa
 /// <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;
 }
示例#3
0
 /// <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;
 }
示例#4
0
 /// <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;
 }
示例#5
0
        public                     Point2l[] ToArray()
        {
            var result = new Point2l[Count];

            for (int i = 0; i < Count; ++i)
            {
                result[i] = this[i];
            }
            return(result);
        }
示例#6
0
        /// <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));
        }
示例#7
0
        /// <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)));
        }
示例#8
0
文件: Line2l.cs 项目: bonomali/Ibasa
 /// <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;
 }
示例#9
0
 /// <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)));
 }
示例#10
0
 /// <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));
 }
示例#11
0
 /// <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)));
 }
示例#12
0
 /// <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));
 }
示例#13
0
 /// <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));
 }
示例#14
0
 /// <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));
 }
示例#15
0
 /// <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));
 }
示例#16
0
 /// <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));
 }
示例#17
0
 /// <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)));
 }
示例#18
0
 /// <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));
 }
示例#19
0
 /// <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)));
 }
示例#20
0
 /// <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);
 }
示例#21
0
 /// <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)));
 }
示例#22
0
 /// <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));
 }
示例#23
0
 /// <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)));
 }
示例#24
0
 /// <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));
 }
示例#25
0
 /// <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);
 }
示例#26
0
 /// <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));
 }
示例#27
0
文件: Line2l.cs 项目: bonomali/Ibasa
 /// <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);
 }
示例#28
0
 /// <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);
 }
示例#29
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));
 }
示例#30
0
 /// <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);
 }