/// <summary>Computes the distance between this point and point p1.</summary> /// <remarks>Computes the distance between this point and point p1.</remarks> /// <param name="p1">the other point</param> /// <returns>the distance</returns> public float Distance(Point3f p1) { float dx; float dy; float dz; dx = this.x - p1.x; dy = this.y - p1.y; dz = this.z - p1.z; return (float)Math.Sqrt(dx * dx + dy * dy + dz * dz); }
/// <summary> /// Transforms the point parameter with this Matrix4f and /// places the result back into point. /// </summary> /// <remarks> /// Transforms the point parameter with this Matrix4f and /// places the result back into point. The fourth element of the /// point input paramter is assumed to be one. /// </remarks> /// <param name="point">the input point to be transformed.</param> public void Transform(Point3f point) { float x; float y; x = m00 * point.x + m01 * point.y + m02 * point.z + m03; y = m10 * point.x + m11 * point.y + m12 * point.z + m13; point.z = m20 * point.x + m21 * point.y + m22 * point.z + m23; point.x = x; point.y = y; }
/// <summary>Constructs and initializes a Point3f from the specified Point3f.</summary> /// <remarks>Constructs and initializes a Point3f from the specified Point3f.</remarks> /// <param name="p1">the Point3f containing the initialization x y z data</param> public Point3f(Point3f p1) : base(p1) { }
// Compatible with 1.1 /// <summary> /// Computes the square of the distance between this point and /// point p1. /// </summary> /// <remarks> /// Computes the square of the distance between this point and /// point p1. /// </remarks> /// <param name="p1">the other point</param> /// <returns>the square of the distance</returns> public float DistanceSquared(Point3f p1) { float dx; float dy; float dz; dx = this.x - p1.x; dy = this.y - p1.y; dz = this.z - p1.z; return dx * dx + dy * dy + dz * dz; }
/// <summary> /// Computes the L-infinite distance between this point and /// point p1. /// </summary> /// <remarks> /// Computes the L-infinite distance between this point and /// point p1. The L-infinite distance is equal to /// MAX[abs(x1-x2), abs(y1-y2), abs(z1-z2)]. /// </remarks> /// <param name="p1">the other point</param> /// <returns>the L-infinite distance</returns> public float DistanceLinf(Point3f p1) { float tmp; tmp = Math.Max(Math.Abs(this.x - p1.x), Math.Abs(this.y - p1.y)); return (Math.Max(tmp, Math.Abs(this.z - p1.z))); }
/// <summary> /// Computes the L-1 (Manhattan) distance between this point and /// point p1. /// </summary> /// <remarks> /// Computes the L-1 (Manhattan) distance between this point and /// point p1. The L-1 distance is equal to: /// abs(x1-x2) + abs(y1-y2) + abs(z1-z2). /// </remarks> /// <param name="p1">the other point</param> /// <returns>the L-1 distance</returns> public float DistanceL1(Point3f p1) { return (Math.Abs(this.x - p1.x) + Math.Abs(this.y - p1.y) + Math.Abs(this.z - p1. z)); }
/// <summary> /// Transforms the point parameter with this Matrix4d and /// places the result back into point. /// </summary> /// <remarks> /// Transforms the point parameter with this Matrix4d and /// places the result back into point. The fourth element of the /// point input parameter is assumed to be one. /// </remarks> /// <param name="point">the input point to be transformed.</param> public void Transform(Point3f point) { float x; float y; x = (float)(m00 * point.x + m01 * point.y + m02 * point.z + m03); y = (float)(m10 * point.x + m11 * point.y + m12 * point.z + m13); point.z = (float)(m20 * point.x + m21 * point.y + m22 * point.z + m23); point.x = x; point.y = y; }