Provides access to 3D Ray properties and methods. A ray has one endpoint (its origin) and continues infinitely in one direction.
Description
A Ray is a one-dimensional object defined by an Origin point and a directional Vector. A Ray extends to infinity from the Origin point in the direction of the Vector.
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. | |
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. |
IRay.GetEnumIntersect Method
Not implemented at this release.
Public Function GetEnumIntersect ( _
ByVal targetGeometry As IGeometry _
) As IEnumIntersection
public IEnumIntersection GetEnumIntersect (
IGeometry targetGeometry
);
Remarks
This method is currently not implemented.
IRay.GetPointAtDistance Method
Constructs a point at a distance along the ray.
Public Function GetPointAtDistance ( _
ByVal distance As Double _
) As IPoint
public IPoint GetPointAtDistance (
double distance
);
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;
}
IRay.Intersect Method
Returns a point collection containing all points of intersection, in order along the ray.
Public Sub Intersect ( _
ByVal targetGeometry As IGeometry, _
ByVal intersectionPoints As IPointCollection _
)
public void Intersect (
IGeometry targetGeometry,
IPointCollection intersectionPoints
);
Description
Implemented for Points, Multipoints, Polylines, Polygons, Envelopes, and Multipatches.
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.
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;
}
IRay.Intersects Method
Indicates if the ray intersects the target geometry.
Public Function Intersects ( _
ByVal targetGeometry As IGeometry _
) As Boolean
public bool Intersects (
IGeometry targetGeometry
);
Description
Implemented for Points, Multipoints, Polylines, Polygons, Envelopes, and Multipatches.
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.
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;
}
IRay.Origin Property
The origin point of the ray.
Public Property Origin As IPoint
public IPoint Origin {get; set;}
Description
Returns and sets the Origin of the Ray. The Origin is the starting Point from which the Ray infinitely extends in the direction of its vector.
Remarks
IRay.QueryFirstIntersection Method
Returns the first point of intersection between the ray and the target geometry. The point is set empty if there is no intersection.
Public Sub QueryFirstIntersection ( _
ByVal targetGeometry As IGeometry, _
ByVal intersectionPoint As IPoint _
)
public void QueryFirstIntersection (
IGeometry targetGeometry,
IPoint intersectionPoint
);
Description
Implemented for Points, Multipoints, Polylines, Polygons, Envelopes, and Multipatches.
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.
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;
}
IRay.QueryOrigin Method
Sets a point equal to the ray's origin.
Public Sub QueryOrigin ( _
ByVal vectorOrigin As IPoint _
)
public void QueryOrigin (
IPoint vectorOrigin
);
Description
Returns the Origin of the Ray into the input Point.
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.
IRay.QueryPointAtDistance Method
Queries a point at a distance along the ray.
Public Sub QueryPointAtDistance ( _
ByVal distance As Double, _
ByVal Point As IPoint _
)
public void QueryPointAtDistance (
double distance,
IPoint Point
);
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;
}
IRay.QueryVector Method
Sets a vector equal to a unit vector with the same direction as the ray.
Public Sub QueryVector ( _
ByVal directionVector As IVector3D _
)
public void QueryVector (
IVector3D directionVector
);
Description
Returns the Vector3D of the Ray. The Vector3D determines the direction the Ray extends from its Origin. The Vector of a Ray is always Normalized to a unit vector.
Remarks
IRay.Vector Property
The direction vector of the ray.
Public Property Vector As IVector3D
public IVector3D Vector {get; set;}
Description
Returns and sets the Vector3D of the Ray. The Vector3D determines the direction the Ray extends from its Origin. The Vector of a Ray is always Normalized to a unit vector.
Remarks
Inherited Interfaces
Interfaces | Description |
---|---|
IGeometry | Provides access to members that describe properties and behavior of all geometric objects. |
Classes that implement IRay
Classes | Description |
---|---|
Ray | A 3D ray that begins at a point and extends infinitely along a line in one direction only. |
Remarks
A fixed tolerance value is currently used for the three intersection methods: Intersects(), Intersect(), and QueryFirstIntersection().
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;
}