AbstractedSheep.ShuttleTrackerWorld.Point3D.Magnitude C# (CSharp) Method

Magnitude() public method

Calculate the magnitude of the vector formed between the origin and this point.
public Magnitude ( ) : double
return double
        public double Magnitude()
        {
            return Math.Sqrt(Math.Pow(this.X, 2) + Math.Pow(this.Y, 2) + Math.Pow(this.Z, 2));
        }

Usage Example

Example #1
0
        /// <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);
        }