public double Magnitude() { return Math.Sqrt(Math.Pow(this.X, 2) + Math.Pow(this.Y, 2) + Math.Pow(this.Z, 2)); }
/// <summary> /// Calculate the result of moving this point a given distance towards another point. /// </summary> /// <param name="p">The point to move towards.</param> /// <param name="distance">The distance to move. It is possible to move past either endpoint.</param> /// <returns>A point representing the result of moving this point towards the other.</returns> public Point3D MoveTowards(Point3D p, double distance) { Point3D directionVector = p - this; directionVector = directionVector / directionVector.Magnitude(); return((directionVector * distance) + this); }