GlobeControl中如何根据视角(视线)求三维点和dem表面的交点?

GlobeControl中如何根据视角(视线),求三维点和在dem表面上的交点的高度?
已邀请:

刘峥 - ArcGIS多面手

赞同来自:

【解决办法】:
可以根据角度生成一个单位向量vector,然后根据vector和起始点创建一个IRay,然后用ISurface.Locate求出交点和其高度。
private void get_intersection(string path, string filename, IPoint pt) 
{
//Open a file raster dataset.
IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactoryClass();
IRasterWorkspace rasterWorkspace = (IRasterWorkspace)workspaceFactory.OpenFromFile(path, 0);
IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset(filename);
IRasterBandCollection rasterbands = (IRasterBandCollection)rasterDataset;
IRasterBand rasterband = rasterbands.Item(0);
IRasterSurface rastersurface = new RasterSurfaceClass();
rastersurface.RasterBand = rasterband;
ISurface surface = new RasterSurfaceClass();
surface = rastersurface as ISurface;

//construct sight line ray
IVector3D vector = new Vector3DClass();
vector.XComponent = 0.2;
vector.YComponent = 0;
vector.ZComponent = -1;

//construct vertical ray
//IVector3D vector = new Vector3DClass();
//vector.XComponent = 0;
//vector.YComponent = 0;
//vector.ZComponent = -1;

IRay ray = new RayClass();
ray.Vector = vector;
ray.Origin = pt;

//get intersection point
IPoint inter = new PointClass();
inter = surface.Locate(ray, 1);

double elevation; double z;
elevation = surface.GetElevation(inter);
z = surface.get_Z(inter.X, inter.Y);

要回复问题请先登录注册