This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IR > IRay Interface > IRay.QueryPointAtDistance Method (ArcObjects .NET 10.5 SDK) |
Queries a point at a distance along the ray.
[Visual Basic .NET] Public Sub QueryPointAtDistance ( _ ByVal distance As Double, _ ByVal Point As IPoint _ )
[C#] public void QueryPointAtDistance ( double distance, IPoint Point );
[C++]
HRESULT QueryPointAtDistance(
double distance,
IPoint* Point
);
[C++]
Parameters distance distance is a parameter of type double Point
Point is a parameter of type IPoint
public static void QueryPointAtDistance()
{
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=new PointClass();
ray.QueryPointAtDistance(Distance, point);
//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;
}