Interface IRay

Namespace
ESRI.ArcGIS.Geometry
Assembly
ESRI.Server.Geometry.dll

Provides access to 3D Ray properties and methods. A ray has one endpoint (its origin) and continues infinitely in one direction.

[Guid("0CD38CBA-1C89-11D4-9F5C-00C04F6BDF0D")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IRay : IGeometry

Remarks

A fixed tolerance value is currently used for the three intersection methods: Intersects(), Intersect(), and QueryFirstIntersection().

Ray Example

 

[C#]

    public IRay CreateRay(IPoint point, IVector3D vector)
    {
        IRay ray = new RayClass();
        //If the input point.Z is NAN (Not A Number = value not set) set the z to 0
        if (point.Z.Equals(Double.NaN))
        {
            point.Z = 0;
        }
        ray.Origin = point;
        ray.Vector = vector;








        return ray;
    }

Properties

Dimension

esriGeometryDimension Dimension { get; }

Property Value

esriGeometryDimension

Envelope

IEnvelope Envelope { get; }

Property Value

IEnvelope

GeometryType

esriGeometryType GeometryType { get; }

Property Value

esriGeometryType

IsEmpty

bool IsEmpty { get; }

Property Value

bool

Origin

The origin point of the ray.

IPoint Origin { get; set; }

Property Value

IPoint

Remarks

 

Ray Origin Example

SpatialReference

ISpatialReference SpatialReference { get; set; }

Property Value

ISpatialReference

Vector

The direction vector of the ray.

IVector3D Vector { get; set; }

Property Value

IVector3D

Remarks

 

Ray Vector Example

Methods

GeoNormalize()

void GeoNormalize()

GeoNormalizeFromLongitude(double)

void GeoNormalizeFromLongitude(double Longitude)

Parameters

Longitude double

GetEnumIntersect(IGeometry)

Not implemented at this release.

IEnumIntersection GetEnumIntersect(IGeometry targetGeometry)

Parameters

targetGeometry IGeometry

Returns

IEnumIntersection

Remarks

This method is currently not implemented.

GetPointAtDistance(double)

Constructs a point at a distance along the ray.

IPoint GetPointAtDistance(double distance)

Parameters

distance double

Returns

IPoint

Intersect(IGeometry, IPointCollection)

Returns a point collection containing all points of intersection, in order along the ray.

void Intersect(IGeometry targetGeometry, IPointCollection intersectionPoints)

Parameters

targetGeometry IGeometry
intersectionPoints IPointCollection

Remarks

This method is intended to be called against top-level geometries only (Point, Multipoint, Polyline, Polygon, Envelope, MultiPatch). To call this method against a Segment/Path or Ring, first add the part to a Polyline or Polygon container, respectively, and then call this method against the container.

[C#]

 

 

        public static void QueryPointsOfIntersection()

        {

               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);



IGeometry

 multiPatchGeometry = GetMultiPatchGeometry();

 

               IPointCollection intersectionPointCollection = new MultipointClass();

               ray.Intersect(multiPatchGeometry, intersectionPointCollection);


              
//intersectionPointCollection[0] = (5, -2.13, 0.092)

               //intersectionPointCollection[1] = (1.612, -2.651, 7.012)
        }

        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;

        }

Intersects(IGeometry)

Indicates if the ray intersects the target geometry.

bool Intersects(IGeometry targetGeometry)

Parameters

targetGeometry IGeometry

Returns

bool

Remarks

This method is intended to be called against top-level geometries only (Point, Multipoint, Polyline, Polygon, Envelope, MultiPatch). To call this method against a Segment/Path or Ring, first add the part to a Polyline or Polygon container, respectively, and then call this method against the container.

[C#]

 

        public static void TestIntersection()

        {

               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);



IGeometry

 multiPatchGeometry = GetMultiPatchGeometry();

 

               bool intersects = ray.Intersects(multiPatchGeometry);


              
//intersects = true

        }

        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;

        }



Project(ISpatialReference)

void Project(ISpatialReference newReferenceSystem)

Parameters

newReferenceSystem ISpatialReference

QueryEnvelope(IEnvelope)

void QueryEnvelope(IEnvelope outEnvelope)

Parameters

outEnvelope IEnvelope

QueryFirstIntersection(IGeometry, IPoint)

Returns the first point of intersection between the ray and the target geometry. The point is set empty if there is no intersection.

void QueryFirstIntersection(IGeometry targetGeometry, IPoint intersectionPoint)

Parameters

targetGeometry IGeometry
intersectionPoint IPoint

Remarks

This method is intended to be called against top-level geometries only (Point, Multipoint, Polyline, Polygon, Envelope, MultiPatch). To call this method against a Segment/Path or Ring, first add the part to a Polyline or Polygon container, respectively, and then call this method against the container.

If a Ray intersects an Envelope and is located within the bounds of the Envelope, the result of QueryFirstIntersection will be the point closest to the Ray origin along the Ray, located on the exterior of the Envelope at which an intersection takes place.

[C#]

 

        public static void QueryFirstIntersection()

        {

               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);



IGeometry

 multiPatchGeometry = GetMultiPatchGeometry();

 

               IPoint firstIntersectionPoint = new PointClass();

               ray.QueryFirstIntersection(multiPatchGeometry, firstIntersectionPoint);


              
//firstIntersectionPoint = (5, -2.13, 0.092)

        }

        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;

        }

QueryOrigin(IPoint)

Sets a point equal to the ray's origin.

void QueryOrigin(IPoint vectorOrigin)

Parameters

vectorOrigin IPoint

Remarks

Note: The output geometry must be co-created prior to the query. The output geometry is not co-created by the method; it is populated. This can be used in performance critical situations. For example, creating the geometry only once outside a loop and use the query method could improve performance.

Ray QueryOrigin Example

QueryPointAtDistance(double, IPoint)

Queries a point at a distance along the ray.

void QueryPointAtDistance(double distance, IPoint Point)

Parameters

distance double
Point IPoint

QueryVector(IVector3D)

Sets a vector equal to a unit vector with the same direction as the ray.

void QueryVector(IVector3D directionVector)

Parameters

directionVector IVector3D

Remarks

 

Ray QueryVector Example

SetEmpty()

void SetEmpty()

SnapToSpatialReference()

void SnapToSpatialReference()