コード例 #1
0
ファイル: Point2f.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(Point2f value, Func <float, double> mapping)
 {
     return(new Point2d(mapping(value.X), mapping(value.Y)));
 }
コード例 #2
0
ファイル: Point2f.cs プロジェクト: bonomali/Ibasa
 /// <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
ファイル: Point2f.cs プロジェクト: bonomali/Ibasa
 /// <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
ファイル: Point2f.cs プロジェクト: bonomali/Ibasa
 /// <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
ファイル: Point2f.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 Point2f Modulate(Point2f left, Point2f right)
 {
     return(new Point2f(left.X * right.X, left.Y * right.Y));
 }
コード例 #7
0
ファイル: Point2f.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 Point2f Max(Point2f value1, Point2f value2)
 {
     return(new Point2f(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y)));
 }
コード例 #8
0
ファイル: Point2f.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 Point2f Multiply(Point2f point, float scalar)
 {
     return(new Point2f(point.X * scalar, point.Y * scalar));
 }
コード例 #9
0
ファイル: Point2f.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 Point2f Divide(Point2f point, float scalar)
 {
     return(new Point2f(point.X / scalar, point.Y / scalar));
 }
コード例 #10
0
ファイル: Point2f.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 Vector2f Subtract(Point2f left, Point2f right)
 {
     return(new Vector2f(left.X - right.X, left.Y - right.Y));
 }
コード例 #11
0
ファイル: Point2f.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 Point2f Subtract(Point2f point, Vector2f vector)
 {
     return(new Point2f(point.X - vector.X, point.Y - vector.Y));
 }
コード例 #12
0
ファイル: Point2f.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 Point2f Add(Point2f point, Vector2f vector)
 {
     return(new Point2f(point.X + vector.X, point.Y + vector.Y));
 }
コード例 #13
0
ファイル: Point2f.cs プロジェクト: bonomali/Ibasa
 /// <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
ファイル: Point2f.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(Point2f value, Func <float, long> mapping)
 {
     return(new Point2l(mapping(value.X), mapping(value.Y)));
 }
コード例 #16
0
ファイル: Point2f.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(Point2f left, Point2f right)
 {
     return(left == right);
 }
コード例 #17
0
ファイル: Point2f.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(Point2f value, Func <float, int> mapping)
 {
     return(new Point2i(mapping(value.X), mapping(value.Y)));
 }
コード例 #18
0
ファイル: Point2f.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 float DistanceSquared(Point2f value1, Point2f value2)
 {
     return(Vector.AbsoluteSquared(value2 - value1));
 }
コード例 #19
0
ファイル: Point2f.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 Point2f Abs(Point2f value)
 {
     return(new Point2f(Functions.Abs(value.X), Functions.Abs(value.Y)));
 }
コード例 #20
0
ファイル: Point2f.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 float ManhattenDistance(Point2f value1, Point2f value2)
 {
     return(Functions.Abs(value2.X - value1.X) + Functions.Abs(value2.Y - value1.Y));
 }
コード例 #21
0
ファイル: Point2f.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 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
ファイル: Point2f.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(Point2f value)
 {
     return(value.X != 0 && value.Y != 0);
 }
コード例 #23
0
ファイル: Point2f.cs プロジェクト: bonomali/Ibasa
 /// <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
ファイル: Point2f.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(Point2f value)
 {
     return(value.X != 0 || value.Y != 0);
 }
コード例 #25
0
ファイル: Point2f.cs プロジェクト: bonomali/Ibasa
 /// <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
ファイル: Point2f.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(Point2f value, Predicate <float> predicate)
 {
     return(predicate(value.X) || predicate(value.Y));
 }
コード例 #27
0
ファイル: Point2f.cs プロジェクト: bonomali/Ibasa
 /// <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;
 }