Provides access to 3D Ray properties and methods. A ray has one endpoint (its origin) and continues infinitely in one direction.
Description
This interface is new at ArcGIS 9.3. It supersedes IRay.
Members
| Name | Description | |
|---|---|---|
![]()  | 
Dimension | The topological dimension of this geometry. | 
![]()  | 
Envelope | Creates a copy of this geometry's envelope and returns it. | 
![]()  | 
GeometryType | The type of this geometry. | 
![]()  | 
GeoNormalize | Shifts longitudes, if need be, into a continuous range of 360 degrees. | 
![]()  | 
GeoNormalizeFromLongitude | Normalizes longitudes into a continuous range containing the longitude. This method is obsolete. | 
![]()  | 
GetEnumIntersect | Not implemented at this release. | 
![]()  | 
GetPointAtDistance | Constructs a point at a distance along the ray. | 
![]()  | 
Intersect | Returns a point collection containing all points of intersection, in order along the ray. | 
![]()  | 
Intersects | Indicates if the ray intersects the target geometry. | 
![]()  | 
IsEmpty | Indicates whether this geometry contains any points. | 
![]()  | 
Origin | The origin point of the ray. | 
![]()  | 
Project | Projects this geometry into a new spatial reference. | 
![]()  | 
QueryEnvelope | Copies this geometry's envelope properties into the specified envelope. | 
![]()  | 
QueryFirstIntersection | Returns the first point of intersection between the ray and the target geometry. The point is set empty if there is no intersection. | 
![]()  | 
QueryOrigin | Sets a point equal to the ray's origin. | 
![]()  | 
QueryPlaneIntersection | Returns the point of intersection between the ray and the target plane. The point is set empty if there is no intersection. | 
![]()  | 
QueryPointAtDistance | Queries a point at a distance along the ray. | 
![]()  | 
QueryVector | Sets a vector equal to a unit vector with the same direction as the ray. | 
![]()  | 
SetEmpty | Removes all points from this geometry. | 
![]()  | 
SnapToSpatialReference | Moves points of this geometry so that they can be represented in the precision of the geometry's associated spatial reference system. | 
![]()  | 
SpatialReference | The spatial reference associated with this geometry. | 
![]()  | 
Vector | The direction vector of the ray. | 
IRay2.QueryPlaneIntersection Method
Returns the point of intersection between the ray and the target plane. The point is set empty if there is no intersection.
Public Sub QueryPlaneIntersection ( _
    ByRef pPlaneNormal As WKSPointZ, _
    ByVal D As Double, _
    ByVal pPoint As IPoint _
)
public void QueryPlaneIntersection (
    ref WKSPointZ pPlaneNormal,
    ref double D,
    ref IPoint pPoint
);
Description
Given a plane represented by a point lying in the plane (IPoint pointInPlane) and a vector normal to the plane (IVector3D normalToPlane):
· pPlaneNormal represents the X, Y, and Z components of the normal vector packed into a WKSPointZ struct:
WKSPointZ pPlaneNormal = new WKSPointZ();
pPlaneNormal.X = normalToPlane.XComponent;
pPlaneNormal.Y = normalToPlane.YComponent;
pPlaneNormal.Z = normalToPlane.ZComponent;
· D represents the dot product of the normal vector and a vector whose X, Y, and Z components are set to the X, Y, and Z coordinates of the point lying in the plane:
IVector3D vector3D = new Vector3DClass(); vector3D.SetComponents( pointInPlane.X, pointInPlane.Y, pointInPlane.Z );
double D = normalToPlane.DotProduct(vector3D);
· pPoint represents the point of intersection, and should be set to a new instance of the PointClass() before it is passed to the method:
IPoint point = new PointClass();
public static void QueryPlaneIntersection()
          {
              int seed = DateTime.Now.Millisecond;
  
              Random random = new Random(seed);
  
              IRay2 ray = GetRay(GetLine(GetPoint(random), GetPoint(random)));
  
              IRay planePackedAsRay = GetRay(GetLine(GetPoint(random), GetPoint(random)));
  
              WKSPointZ wksPointZ;
              double distance;
  
              ConstructPlaneParameters(planePackedAsRay.Vector, planePackedAsRay.Origin, out wksPointZ, out distance);
  
              IPoint intersectionPoint = new PointClass();
  
              ray.QueryPlaneIntersection(ref wksPointZ, distance, intersectionPoint);
  
              //intersectionPoint = (-6, -0.913, -7.289)
          }
  
          private static void ConstructPlaneParameters(IVector3D vector3D, IPoint point, out WKSPointZ wksPointZ, out double distance)
          {
              wksPointZ = ConstructWKSPointZ(vector3D);
              distance = vector3D.DotProduct(ConstructVector3D(point.X, point.Y, point.Z));
          }
  
          private static WKSPointZ ConstructWKSPointZ(IVector3D vector3D)
          {
              WKSPointZ wksPointZ = new WKSPointZ();
              wksPointZ.X = vector3D.XComponent;
              wksPointZ.Y = vector3D.YComponent;
              wksPointZ.Z = vector3D.ZComponent;
  
              return wksPointZ;
          }
  
          private static IRay2 GetRay(ILine line)
          {
              IRay2 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);
  
              return ray;
          }
  
          private static ILine GetLine(IPoint fromPoint, IPoint toPoint)
          {
              ILine line = new LineClass();
              line.FromPoint = fromPoint;
              line.ToPoint = toPoint;
  
              return line;
          }
  
          private static IPoint GetPoint(Random random)
          {
              const double Min = -10;
              const double Max = 10;
  
              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;
          }
Inherited Interfaces
| Interfaces | Description | 
|---|---|
| IRay | Provides access to 3D Ray properties and methods. A ray has one endpoint (its origin) and continues infinitely in one direction. | 
| IGeometry | Provides access to members that describe properties and behavior of all geometric objects. | 
Classes that implement IRay2
| Classes | Description | 
|---|---|
| Ray | A 3D ray that begins at a point and extends infinitely along a line in one direction only. | 
public IRay2 CreateRay(IPoint point, IVector3D vector)
    {
        IRay2 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;
    }



