Пример #1
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(Point2f value, Func <float, double> mapping)
 {
     return(new Point2d(mapping(value.X), mapping(value.Y)));
 }
Пример #2
0
 /// <summary>
 /// Returns a point where each component is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A point.</param>
 /// <returns>The result of rounding value.</returns>
 public static Point2f Round(Point2f value)
 {
     return(new Point2f(Functions.Round(value.X), Functions.Round(value.Y)));
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Line2f"/> 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 Line2f(float startX, float startY, float endX, float endY)
 {
     Start = new Point2f(startX, startY);
     End   = new Point2f(endX, endY);
 }
Пример #4
0
 /// <summary>
 /// Returns a point where each component is the smallest integral value that
 /// is greater than or equal to the specified component.
 /// </summary>
 /// <param name="value">A point.</param>
 /// <returns>The ceiling of value.</returns>
 public static Point2f Ceiling(Point2f value)
 {
     return(new Point2f(Functions.Ceiling(value.X), Functions.Ceiling(value.Y)));
 }
Пример #5
0
 /// <summary>
 /// Returns a point where each component is the integral part of the specified component.
 /// </summary>
 /// <param name="value">A point.</param>
 /// <returns>The integral of value.</returns>
 public static Point2f Truncate(Point2f value)
 {
     return(new Point2f(Functions.Truncate(value.X), Functions.Truncate(value.Y)));
 }
Пример #6
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 Point2f Modulate(Point2f left, Point2f right)
 {
     return(new Point2f(left.X * right.X, left.Y * right.Y));
 }
Пример #7
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 Point2f Max(Point2f value1, Point2f value2)
 {
     return(new Point2f(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y)));
 }
Пример #8
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 Point2f Multiply(Point2f point, float scalar)
 {
     return(new Point2f(point.X * scalar, point.Y * scalar));
 }
Пример #9
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 Point2f Divide(Point2f point, float scalar)
 {
     return(new Point2f(point.X / scalar, point.Y / scalar));
 }
Пример #10
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 Vector2f Subtract(Point2f left, Point2f right)
 {
     return(new Vector2f(left.X - right.X, left.Y - right.Y));
 }
Пример #11
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 Point2f Subtract(Point2f point, Vector2f vector)
 {
     return(new Point2f(point.X - vector.X, point.Y - vector.Y));
 }
Пример #12
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 Point2f Add(Point2f point, Vector2f vector)
 {
     return(new Point2f(point.X + vector.X, point.Y + vector.Y));
 }
Пример #13
0
 /// <summary>
 /// Writes the given <see cref="Point2f"/> to an <see cref="Ibasa.IO.BinaryWriter">.
 /// </summary>
 public static void Write(this Ibasa.IO.BinaryWriter writer, Point2f point)
 {
     writer.Write(point.X);
     writer.Write(point.Y);
 }
Пример #14
0
 public static bool Contains(Rectanglef rectangle, Point2f point)
 {
     return((rectangle.Left <= point.X) && (rectangle.Right >= point.X) &&
            (rectangle.Bottom <= point.Y) && (rectangle.Top >= point.Y));
 }
Пример #15
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 Point2l Map(Point2f value, Func <float, long> mapping)
 {
     return(new Point2l(mapping(value.X), mapping(value.Y)));
 }
Пример #16
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(Point2f left, Point2f right)
 {
     return(left == right);
 }
Пример #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 Point2i Map(Point2f value, Func <float, int> mapping)
 {
     return(new Point2i(mapping(value.X), mapping(value.Y)));
 }
Пример #18
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 float DistanceSquared(Point2f value1, Point2f value2)
 {
     return(Vector.AbsoluteSquared(value2 - value1));
 }
Пример #19
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 Point2f Abs(Point2f value)
 {
     return(new Point2f(Functions.Abs(value.X), Functions.Abs(value.Y)));
 }
Пример #20
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 float ManhattenDistance(Point2f value1, Point2f value2)
 {
     return(Functions.Abs(value2.X - value1.X) + Functions.Abs(value2.Y - value1.Y));
 }
Пример #21
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 Point2f Clamp(Point2f value, Point2f min, Point2f max)
 {
     return(new Point2f(Functions.Clamp(value.X, min.X, max.X), Functions.Clamp(value.Y, min.Y, max.Y)));
 }
Пример #22
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(Point2f value)
 {
     return(value.X != 0 && value.Y != 0);
 }
Пример #23
0
 /// <summary>
 /// Returns a point where each component is the largest integral value that
 /// is less than or equal to the specified component.
 /// </summary>
 /// <param name="value">A point.</param>
 /// <returns>The floor of value.</returns>
 public static Point2f Floor(Point2f value)
 {
     return(new Point2f(Functions.Floor(value.X), Functions.Floor(value.Y)));
 }
Пример #24
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(Point2f value)
 {
     return(value.X != 0 || value.Y != 0);
 }
Пример #25
0
 /// <summary>
 /// Returns a point where each component is the fractional part of the specified component.
 /// </summary>
 /// <param name="value">A point.</param>
 /// <returns>The fractional of value.</returns>
 public static Point2f Fractional(Point2f value)
 {
     return(new Point2f(Functions.Fractional(value.X), Functions.Fractional(value.Y)));
 }
Пример #26
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(Point2f value, Predicate <float> predicate)
 {
     return(predicate(value.X) || predicate(value.Y));
 }
Пример #27
0
 /// <summary>
 /// Returns a point where each component is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A point.</param>
 /// <param name="digits">The number of fractional digits in the return value.</param>
 /// <returns>The result of rounding value.</returns>
 public static Point2f Round(Point2f value, int digits)
 {
     return(new Point2f(Functions.Round(value.X, digits), Functions.Round(value.Y, digits)));
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Line2f"/> using the specified values.
 /// </summary>
 /// <param name="start">Start point of the line.</param>
 /// <param name="end">End point of the line.</param>
 public Line2f(Point2f start, Point2f end)
 {
     Start = start;
     End   = end;
 }