ArcObjects Library Reference (Geometry)  

IRay.GetPointAtDistance Method

Constructs a point at a distance along the ray.

[Visual Basic .NET]
Public Function GetPointAtDistance ( _
    ByVal distance As Double _
) As IPoint
[C#]
public IPoint GetPointAtDistance (
    double distance
);
[C++]
HRESULT GetPointAtDistance(
  double distance,
  IPoint** Point
);
[C++]

Parameters

distance   distance is a parameter of type double Point [out, retval]

  Point is a parameter of type IPoint

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.
[C#]

 

        public static void GetPointAtDistance()

        {

               const double Distance = 8.822;


               ILine line = new LineClass();
               line.FromPoint = GetPoint();
               line.ToPoint = GetPoint();

               IRay ray = new RayClass();
               ray.Origin = line.FromPoint;
               ray.Vector = ConstructVector3D(line.ToPoint.X - line.FromPoint.X, line.ToPoint.Y - line.FromPoint.Y, line.ToPoint.Z - line.FromPoint.Z);

 

               IPoint point = ray.GetPointAtDistance(Distance);


              
//point = (5.244, 3.749, 4.738)

        }

        private static IPoint GetPoint()

        {

            const double Min = -10;

            const double Max = 10;

 

            Random random = new Random();

 

            double x = Min + (Max - Min) * random.NextDouble();

            double y = Min + (Max - Min) * random.NextDouble();

            double z = Min + (Max - Min) * random.NextDouble();

 

            IPoint point = ConstructPoint3D(x, y, z);

 

            MakeZAware(point as IGeometry);

 

            return point;

        }

 

        private static IPoint ConstructPoint3D(double x, double y, double z)

        {

            IPoint point = ConstructPoint2D(x, y);

            point.Z = z;

           
return point;

        }

        private static IPoint ConstructPoint2D(double x, double y)

        {

            IPoint point = new PointClass();

            point.PutCoords(x, y);
 

            return point;

        }

        private static void MakeZAware(IGeometry geometry)

        {

            IZAware zAware = geometry as IZAware;

            zAware.ZAware = true;

        }

 

        public static IVector3D ConstructVector3D(double xComponent, double yComponent, double zComponent)

        {

            IVector3D vector3D = new Vector3DClass();

            vector3D.SetComponents(xComponent, yComponent, zComponent);

 

            return vector3D;

        }

 

See Also

IRay Interface