protected PointSet(PointSet p) : this(p.Size) { for (int i = 0; i < Size; i++) { Ponderance[i] = p.Ponderance[i]; } }
public Point(PointSet p) : base(p) { }
/// <summary> /// Adds a point and a vector to produce a new point. /// </summary> /// <param name="a">A point.</param> /// <param name="b">A vector.</param> /// <returns>The point <paramref name="a"/> + <paramref name="b"/>.</returns> public static Point Add(PointSet a, Vector b) { return(Vector.Add(a.ToVector(), b).ToPoint()); }
/// <summary> /// Subtracts a vector from a point to produce a new point. /// </summary> /// <param name="a">A point.</param> /// <param name="b">A vector.</param> /// <returns>The point <paramref name="a"/> - <paramref name="b"/>.</returns> public static Point Subtract(PointSet a, Vector b) { return(Subtract(a, b.ToPoint()).ToPoint()); }
/// <summary> /// The geometry distance between this two points. /// </summary> /// <param name="a">The first point.</param> /// <param name="b">The second point.</param> /// <returns>The distance between them.</returns> public static double Distance(PointSet a, PointSet b) { return(Subtract(a, b).Length); }
/// <summary> /// Subtracts a point from a point to produce a vector. /// </summary> /// <param name="a">The first point.</param> /// <param name="b">The second point.</param> /// <returns>The vector <paramref name="a"/> - <paramref name="b"/>.</returns> public static Vector Subtract(PointSet a, PointSet b) { if (!a.isRegular || !b.isRegular) { throw (new PointNotRegularException()); } if (a.Dimension != b.Dimension) { throw (new DimensionsNotEqualException()); } double[] d = new double[a.Dimension]; for (int i = 0; i < a.Dimension; i++) { d[i] = a[i] - b[i]; } return new Vector(d); }
/// <summary> /// Subtracts a vector from a point to produce a new point. /// </summary> /// <param name="a">A point.</param> /// <param name="b">A vector.</param> /// <returns>The point <paramref name="a"/> - <paramref name="b"/>.</returns> public static Point Subtract(PointSet a, Vector b) { return Subtract(a, b.ToPoint()).ToPoint(); }
/// <summary> /// Multiplies a point by a scalar to produce a new point. /// </summary> /// <param name="a">A scalar.</param> /// <param name="b">A point.</param> /// <returns>The image of <paramref name="b"/> in the scaling centered at the /// origin with ratio <paramref name="a"/>.</returns> public static Point Multiply(double a, PointSet b) { if (!b.isRegular) { throw (new PointNotRegularException()); } double[] d = new double[b.Dimension]; for (int i = 0; i < b.Dimension; i++) { d[i] = a * b[i]; } return new Point(d); }
/// <summary> /// Returns the point midway between two points. /// </summary> /// <param name="a">The first point.</param> /// <param name="b">The second point.</param> /// <returns>The point (<paramref name="a"/> + <paramref name="b"/>)/2.</returns> public static Point MidPoint(PointSet a, PointSet b) { if (!a.isRegular || !b.isRegular) { throw (new PointNotRegularException()); } return ((a.ToVector() + b.ToVector()) / 2).ToPoint(); }
/// <summary> /// The geometry distance between this two points. /// </summary> /// <param name="a">The first point.</param> /// <param name="b">The second point.</param> /// <returns>The distance between them.</returns> public static double Distance(PointSet a, PointSet b) { return Subtract(a, b).Length; }
/// <summary> /// Determines whether two pionts are exactly equal. /// </summary> /// <param name="a">The first vector.</param> /// <param name="b">The second vector.</param> /// <returns><c>true</c> if the two vectors are equal; otherwise, <c>false</c>.</returns> public static bool Compare(PointSet a, PointSet b) { if ((object)a == null && (object)b == null) { return true; } else if ((object)a == null && (object)b != null) { return false; } else { return a.Equals(b); } }
/// <summary> /// Adds a point and a vector to produce a new point. /// </summary> /// <param name="a">A point.</param> /// <param name="b">A vector.</param> /// <returns>The point <paramref name="a"/> + <paramref name="b"/>.</returns> public static Point Add(PointSet a, Vector b) { return Vector.Add(a.ToVector(), b).ToPoint(); }