用GeoRegion3D拟合绘制球面的一部分,但结果出来是椭球面的一部分

0 投票
                    double PI = Math.PI;
                    PrjCoordSys prj = new PrjCoordSys(PrjCoordSysType.Wgs1984WorldMercator);
                    double angle_gap = 5.0;

                    // 球心的地理坐标转投影坐标
                    Point2D center2d = new Point2D(x, y);
                    Point2Ds center2ds = new Point2Ds();
                    center2ds.Add(center2d);
                    CoordSysTranslator.Forward(center2ds, prj);
                    double centerx = center2ds[0].X, centery = center2ds[0].Y;  
                      
                    // 用GeoRegion3D拟合球面
                        for (double yaw = 0.0; yaw < 360.0; yaw += angle_gap)
                        {
                            double radyaw = yaw * PI / 180.0;
                            double sinyaw = Math.Sin(radyaw);
                            double cosyaw = Math.Cos(radyaw);

                            double yaw2 = yaw + angle_gap;
                            double radyaw2 = yaw2 * PI / 180.0;
                            double sinyaw2 = Math.Sin(radyaw2);
                            double cosyaw2 = Math.Cos(radyaw2);

                            for (double pitch = -90.0; pitch < 90.0; pitch += angle_gap)
                            {
                                double radpitch = pitch * PI / 180.0;
                                double sinpitch = Math.Sin(radpitch);
                                double cospitch = Math.Cos(radpitch);

                                double pitch2 = pitch + angle_gap;
                                double radpitch2 = pitch2 * PI / 180.0;
                                double sinpitch2 = Math.Sin(radpitch2);
                                double cospitch2 = Math.Cos(radpitch2);

                                // 用一个GeoRegion3D拟合球面的一小部分
                                double x1 = r * cospitch * cosyaw, 
                                       y1 = r * cospitch * sinyaw, 
                                       z1 = r * sinpitch;

                                double x2 = r * cospitch * cosyaw2, 
                                       y2 = r * cospitch * sinyaw2, 
                                       z2 = r * sinpitch;

                                double x3 = r * cospitch2 * cosyaw2, 
                                       y3 = r * cospitch2 * sinyaw2, 
                                       z3 = r * sinpitch2;

                                double x4 = r * cospitch2 * cosyaw, 
                                       y4 = r * cospitch2 * sinyaw, 
                                       z4 = r * sinpitch2;

                                // GeoRegion3D的投影坐标转地理坐标
                                Point2Ds pts2d = new Point2Ds();
                                pts2d.Add(new Point2D(x1 + centerx, y1 + centery));
                                pts2d.Add(new Point2D(x2 + centerx, y2 + centery));
                                pts2d.Add(new Point2D(x3 + centerx, y3 + centery));
                                pts2d.Add(new Point2D(x4 + centerx, y4 + centery));
                                CoordSysTranslator.Inverse(pts2d, prj);

                                
                                Point3Ds pts = new Point3Ds();
                                pts.Add(new Point3D(pts2d[0].X, pts2d[0].Y, z + z1));
                                pts.Add(new Point3D(pts2d[1].X, pts2d[1].Y, z + z2));
                                pts.Add(new Point3D(pts2d[2].X, pts2d[2].Y, z + z3));
                                pts.Add(new Point3D(pts2d[3].X, pts2d[3].Y, z + z4));
                                region3d.AddPart(pts);
                            }
                        }
                    
                    
                    recordset.AddNew(geomodel);
                    recordset.Update();

                    Layer3DSettingVector setting = new Layer3DSettingVector();
                    Layer3DDataset layer = layers.Add(dataset, setting, true);
                    layer.IsEditable = true;
                    layer.IsSelectable = true;
                    layer.IsVisible = true;
                    layer.CullMode = CullModeType.NONE;
                    layer.MaxObjectVisibleDistance = double.MaxValue;
                    layer.MaxVisibleAltitude = double.MaxValue;
                    layer.UpdateData();

iobject  .NET 桌面端二次开发

要生成球面或球面的一部分,但最终出来的结果是一个椭球面

<!--StartFragment -->

我查了代码,z坐标的计算应该没有问题,不知道咋回事儿。

7月 3 分类:  37次浏览 | 用户: zuoxinkai (7 分)
重新分类 7月 6 用户:三次鱼疯啦

1个回答

0 投票
那是因为地球椭球体本身就是椭圆,投影转换是存在有一定误差的,如果想要正圆,可以直接使用supermap提供的三维球对象:

 GeoSphere geoSphere = new GeoSphere(new Point3D(115, 23, 5), 2);

GeoModel3D geomodel = geoSphere.ConvertToGeoModel3D(true,99);
7月 6 用户: 程逸诗 名扬四海 (2,417 分)
我想要绘制的是球的一部分,

通过GeoRegion3D来拟合球面

然后加上其他的面,组成球的一部分的外表面。

不能用GeoSphere
...