Translate Point Along a Vector

Print Friendly, PDF & Email

Translate Point Along a Vector

This is done in a series of small steps;

  • Calculate the Magnitude of the Vector
  • Calculate the Unit Vector
  • Translate the Point

Translate Reference Point (R) = 10 ; 20 ; 30 10units along Vector (N) = 5 ; 2 ; 7

Magnitude of Vector N

||N|| = \sqrt{I^2 + J^2 + K^2} \\
= \sqrt{5^2 + 2^2 + 7^2} \\
= \sqrt{ 25 + 4 + 49} \\
 = \sqrt{ 78 } \\
= 8.8317

Unit Vector of Vector N

\widehat{N} = \overrightarrow{N} / ||{N}|| \\
= 5 / 8.8317 ; 2 / 8.8317 ; 7 / 8.8317 \\
= 0.5661 ; 0.2264 ; 0.7925

Translate the Point

Point(T) = (\widehat{N} \cdotp Translation \space Length ) + Point(R) \\
X\tiny{T}\cdotp \normalsize = (0.5661 \cdotp 10) + 10 = 15.66139 \\
Y\tiny{T}\cdotp \normalsize = (0.2264 \cdotp 10) + 20 = 22.26455 \\
Z\tiny{T}\cdotp \normalsize = (0.7925 \cdotp 10) + 30 = 37.92594 \\

We can write a simple C# method for doing this with three inputs:

  • A Reference Point, a location in space to start the translation from.
  • A Reference Vector, the direction along which we want to translate the vector.
  • The Offset amount, the distance by which we want to translate the point.
private IPointBase3D TranslatePointAlongVector(IPointBase3D iRefPoint, IVectorBase3D iRefVector, double iOffset)
{
  IPointBase3D ReturnPoint = new PointBase3D();
  ReturnPoint.X = (iRefVector.UnitVector.I * iOffset) + iRefPoint.X;
  ReturnPoint.Y = (iRefVector.UnitVector.J * iOffset) + iRefPoint.Y;
  ReturnPoint.Z = (iRefVector.UnitVector.K * iOffset) + iRefPoint.Z;
  return ReturnPoint;
}

We can take this one step further and use a Reference Axis System to create a Point by Coordinates, using the translation method above.

public PointByCoordinates(IAxisSystemBase3D iRefAxisSystem, double iX, double iY, double iZ)
        {
            this.RefAxisSystem = iRefAxisSystem;
            IPointBase3D NewPoint = this.TranslatePointAlongVector(iRefAxisSystem.Origin, iRefAxisSystem.XAxis,iX);
            NewPoint = this.TranslatePointAlongVector(NewPoint, iRefAxisSystem.YAxis, iY);
            NewPoint = this.TranslatePointAlongVector(NewPoint, iRefAxisSystem.ZAxis, iZ);
            this.X = NewPoint.X;
            this.Y = NewPoint.Y;
            this.Z = NewPoint.Z;
        }

You can download an excel spreadsheet here with the proof.