/// <summary> /// 求导线(pRefPoint到pEndPoint)上的掘进点 /// </summary> /// <params name="pRefPoint">参考导线点</params> /// <params name="pEndPoint">导线的终点</params> /// <params name="dDistance">距离参考导线点的距离</params> /// <returns>距参考导线点一定距离的点</returns> public static IPoint GetJJPoint(IPoint pRefPoint, IPoint pEndPoint, double dDistance) { if (pRefPoint.Z.Equals(Double.NaN)) { pRefPoint.Z = 0; } if (pEndPoint.Z.Equals(Double.NaN)) { pEndPoint.Z = 0; } IVector3D vector3D = new Vector3DClass(); vector3D.ConstructDifference(pEndPoint, pRefPoint); //从参考点到导线终点的向量 vector3D.Normalize(); //向量单位化 IPoint pJjPoint = new PointClass(); pJjPoint.X = pRefPoint.X + dDistance * vector3D.XComponent; pJjPoint.Y = pRefPoint.Y + dDistance * vector3D.YComponent; pJjPoint.Z = pRefPoint.Z + dDistance * vector3D.ZComponent; return(pJjPoint); }
public IGeometry CreateSphere(IPoint centerPoint, double radius, double minLon = 0.0, double maxLon = 360.0, double minLat = -90.0, double maxLat = 90.0, double stepAngle = 18.0, bool bSmooth = false, bool bFlipS = false, bool bFlipT = false) { IMultiPatch patch = new MultiPatchClass(); IGeometryCollection pGCol = patch as IGeometryCollection; IGeometry2 pGeom; IPoint pt; IPointCollection pStrip; IVector3D pVector = new Vector3DClass(); IEncode3DProperties pGE = new GeometryEnvironmentClass(); double xStep = (maxLon - minLon) / stepAngle; double yStep = (maxLat - minLat) / (stepAngle / 2.0); double lonRange = maxLon - minLon; double latRange = maxLat - minLat; object missing = Type.Missing; double lon = minLon; while (lon < maxLon) { pStrip = new TriangleStripClass(); double lat = minLat; while (lat < maxLat) { double azi = DegreesToRadians(lon); double inc = DegreesToRadians(lat); pVector.PolarSet(-azi, inc, radius); pt = new PointClass(); pt.X = centerPoint.X + pVector.XComponent; pt.Y = centerPoint.Y + pVector.YComponent; pt.Z = centerPoint.Z + pVector.ZComponent; double s = (lon - minLon) / lonRange; if (bFlipS) { s = 1 + (s * -1); } if (s <= 0) { s = 0.001; } else if (s >= 1) { s = 0.999; } double t = (maxLat - lat) / latRange; if (bFlipT) { t = 1 + (t * -1); } if (t <= 0) { t = 0.001; } else if (t >= 1) { t = 0.999; } double m = 0.0; pGE.PackTexture2D(s, t, out m); if (bSmooth) { pVector.Normalize(); pGE.PackNormal(pVector, out m); } pt.M = m; pStrip.AddPoint(pt, ref missing, ref missing); if ((lat != -90) && (lat != 90)) { azi = (lon + xStep) * Math.PI / 180.00; inc = lat * Math.PI / 180.00; pVector.PolarSet(-azi, inc, radius); pt = new PointClass(); pt.X = centerPoint.X + pVector.XComponent; pt.Y = centerPoint.Y + pVector.YComponent; pt.Z = centerPoint.Z + pVector.ZComponent; s = (lon + xStep - minLon) / lonRange; if (bFlipS) { s = 1 + (s * -1); } if (s <= 0) { s = 0.001; } else if (s >= 1) { s = 0.999; } t = (maxLat - lat) / latRange; if (bFlipT) { t = 1 + (t * -1); } if (t <= 0) { t = 0.001; } else if (t >= 1) { t = 0.999; } m = 0.0; pGE.PackTexture2D(s, t, out m); if (bSmooth) { pVector.Normalize(); pGE.PackNormal(pVector, out m); } pt.M = m; pStrip.AddPoint(pt, ref missing, ref missing); } lat = lat + yStep; } pGeom = pStrip as IGeometry2; pGCol.AddGeometry(pGeom, ref missing, ref missing); lon = lon + xStep; } IMAware pMAware = patch as IMAware; pMAware.MAware = true; return(patch); }
/// <summary> /// 求导线(pRefPoint到pEndPoint)上的掘进点 /// </summary> /// <params name="pRefPoint">参考导线点</params> /// <params name="pEndPoint">导线的终点</params> /// <params name="dDistance">距离参考导线点的距离</params> /// <returns>距参考导线点一定距离的点</returns> public static IPoint GetJJPoint(IPoint pRefPoint, IPoint pEndPoint, double dDistance) { if (pRefPoint.Z.Equals(Double.NaN)) { pRefPoint.Z = 0; } if (pEndPoint.Z.Equals(Double.NaN)) { pEndPoint.Z = 0; } IVector3D vector3D = new Vector3DClass(); vector3D.ConstructDifference(pEndPoint, pRefPoint); //从参考点到导线终点的向量 vector3D.Normalize(); //向量单位化 IPoint pJjPoint = new PointClass(); pJjPoint.X = pRefPoint.X + dDistance * vector3D.XComponent; pJjPoint.Y = pRefPoint.Y + dDistance * vector3D.YComponent; pJjPoint.Z = pRefPoint.Z + dDistance * vector3D.ZComponent; return pJjPoint; }