/// <summary> /// Initializes a new instance of the <see cref="Spherel"/> using the specified location and radius. /// </summary> /// <param name="center">The center of the sphere.</param> /// <param name="radius">The radius of the sphere.</param> public Spherel(Point3l center, long radius) { Contract.Requires(0 <= radius); X = center.X; Y = center.Y; Z = center.Z; Radius = radius; }
/// <summary> /// Initializes a new instance of the <see cref="Boxl"/> using the specified location and size. /// </summary> /// <param name="location">The front-lower-left corner of the box.</param> /// <param name="size">The size of the box.</param> public Boxl(Point3l location, Size3l size) { X = location.X; Y = location.Y; Z = location.Z; Width = size.Width; Height = size.Height; Depth = size.Depth; }
/// <summary> /// Initializes a new instance of the <see cref="Boxl"/> using the specified location and size. /// </summary> /// <param name="location">The front-lower-left corner of the box.</param> /// <param name="width">Value for the Width component of the box.</param> /// <param name="height">Value for the Height component of the box.</param> /// <param name="depth">Value for the Depth component of the box.</param> public Boxl(Point3l location, long width, long height, long depth) { X = location.X; Y = location.Y; Z = location.Z; Width = width; Height = height; Depth = depth; }
public Point3l[] ToArray() { var result = new Point3l[Count]; for (int i = 0; i < Count; ++i) { result[i] = this[i]; } return(result); }
/// <summary> /// Reads a <see cref="Polygon3l"/> from an <see cref="Ibasa.IO.BinaryReader">. /// </summary> public static Polygon3l ReadPolygon3l(this Ibasa.IO.BinaryReader reader) { var length = reader.ReadInt32(); var array = new Point3l[length]; for (int i = 0; i < length; ++i) { array[i] = reader.ReadPoint3l(); } return(new Polygon3l(array)); }
/// <summary> /// Transforms a point in cartesian coordinates to spherical coordinates. /// </summary> /// <param name="value">The point to transform.</param> /// <returns>The spherical coordinates of value.</returns> public static SphericalCoordinate CartesianToSpherical(Point3l value) { double r = Functions.Sqrt(value.X * value.X + value.Y * value.Y + value.Z * value.Z); double theta = Functions.Atan2(value.Y, value.X); if (theta < 0) { theta += 2 * Constants.Pi; } return(new SphericalCoordinate( r, (double)Functions.Acos(value.Z / r), theta)); }
/// <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(Point3l value, Predicate <long> predicate) { return(predicate(value.X) || predicate(value.Y) || predicate(value.Z)); }
/// <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(Point3l value) { return(value.X != 0 || value.Y != 0 || value.Z != 0); }
/// <summary> /// Determines whether all 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 every component of the point passes the test in the specified /// predicate; otherwise, false.</returns> public static bool All(Point3l value, Predicate <long> predicate) { return(predicate(value.X) && predicate(value.Y) && predicate(value.Z)); }
/// <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(Point3l value) { return(value.X != 0 && value.Y != 0 && value.Z != 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 Point3l Abs(Point3l value) { return(new Point3l(Functions.Abs(value.X), Functions.Abs(value.Y), Functions.Abs(value.Z))); }
/// <summary> /// Writes the given <see cref="Point3l"/> to an <see cref="Ibasa.IO.BinaryWriter">. /// </summary> public static void Write(this Ibasa.IO.BinaryWriter writer, Point3l point) { writer.Write(point.X); writer.Write(point.Y); writer.Write(point.Z); }
/// <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 Point3l Map(Point3l value, Func <long, long> mapping) { return(new Point3l(mapping(value.X), mapping(value.Y), mapping(value.Z))); }
/// <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(Point3l left, Point3l right) { return(left == right); }
/// <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 Point3l Divide(Point3l point, long scalar) { return(new Point3l(point.X / scalar, point.Y / scalar, point.Z / scalar)); }
/// <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 Point3l Multiply(Point3l point, long scalar) { return(new Point3l(point.X * scalar, point.Y * scalar, point.Z * 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 Point3l Subtract(Point3l point, Vector3l vector) { return(new Point3l(point.X - vector.X, point.Y - vector.Y, point.Z - vector.Z)); }
/// <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 Vector3l Subtract(Point3l left, Point3l right) { return(new Vector3l(left.X - right.X, left.Y - right.Y, left.Z - right.Z)); }
/// <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 Point3l Add(Point3l point, Vector3l vector) { return(new Point3l(point.X + vector.X, point.Y + vector.Y, point.Z + vector.Z)); }
/// <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 Point3d Map(Point3l value, Func <long, double> mapping) { return(new Point3d(mapping(value.X), mapping(value.Y), mapping(value.Z))); }
/// <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 Point3f Map(Point3l value, Func <long, float> mapping) { return(new Point3f(mapping(value.X), mapping(value.Y), mapping(value.Z))); }
/// <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 Point3l Clamp(Point3l value, Point3l min, Point3l max) { return(new Point3l(Functions.Clamp(value.X, min.X, max.X), Functions.Clamp(value.Y, min.Y, max.Y), Functions.Clamp(value.Z, min.Z, max.Z))); }
public static bool Contains(Spherel sphere, Point3l point) { return(Vector.AbsoluteSquared(sphere.Center - point) <= sphere.Radius * sphere.Radius); }
/// <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(Point3l point, Vector3l vector) { return(vector.X * point.X + vector.Y * point.Y + vector.Z * point.Z); }
/// <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(Point3l value1, Point3l value2) { return(Vector.Absolute(value2 - value1)); }
/// <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 Point3l Max(Point3l value1, Point3l value2) { return(new Point3l(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y), Functions.Max(value1.Z, value2.Z))); }
public static bool Contains(Boxl box, Point3l point) { return((box.Left <= point.X) && (box.Right >= point.X) && (box.Bottom <= point.Y) && (box.Top >= point.Y) && (box.Front <= point.Z) && (box.Back >= point.Z)); }
/// <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(Point3l value1, Point3l value2) { return(Vector.AbsoluteSquared(value2 - value1)); }
/// <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(Point3l value1, Point3l value2) { return(Functions.Abs(value2.X - value1.X) + Functions.Abs(value2.Y - value1.Y) + Functions.Abs(value2.Z - value1.Z)); }
/// <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 Point3l Modulate(Point3l left, Point3l right) { return(new Point3l(left.X * right.X, left.Y * right.Y, left.Z * right.Z)); }