Exemple #1
0
        /*
         *
         * public static Vector3[] ScaleDown(ref Vector3[] pts)
         * {
         * for (int i = 0; i < pts.Length; i++)
         * {
         *  pts[i].X = pts[i].X * rX;
         *  pts[i].Y = pts[i].X * rY;
         *  pts[i].Z = pts[i].X * rZ;
         * }
         *
         * }
         */

        // from https://cesiumjs.org/2013/05/09/Computing-the-horizon-occlusion-point/
        public static Vector3 FromPoints(Vector3[] points, BBSphere boundingSphere)
        {
            if (points.Length < 1)
            {
                throw new Exception("Your list of points must contain at least 2 points");
            }

            // Bring coordinates to ellipsoid scaled coordinates
            for (int i = 0; i < points.Length; i++)
            {
                points[i].X = points[i].X * rX;
                points[i].Y = points[i].Y * rY;
                points[i].Z = points[i].Z * rZ;
            }

            // var scaledPoints = map(scaleDown, points).ToList();

            //   var scaledSphereCenter = scaleDown(boundingSphere.center);
            boundingSphere.Center.X = boundingSphere.Center.X * rX;
            boundingSphere.Center.Y = boundingSphere.Center.Y * rY;
            boundingSphere.Center.Z = boundingSphere.Center.Z * rZ;

            //      Func<object, object> magnitude = coord => {
            //      return computeMagnitude(coord, scaledSphereCenter);
            //   };

            //  List<Double> magnitudes = new List<double>();
            Double maxMagnitude = double.NegativeInfinity;

            for (int i = 0; i < points.Length; i++)
            {
                //magnitudes.Add(ComputeMagnitude(points[i], boundingSphere.Center));
                var magnitude = ComputeMagnitude(points[i], boundingSphere.Center);
                if (magnitude > maxMagnitude)
                {
                    maxMagnitude = magnitude;
                }
            }


            //  var magnitudes = map(magnitude, scaledPoints).ToList();

            return(Cartesian3D.MultiplyByScalar(boundingSphere.Center, maxMagnitude));
        }
Exemple #2
0
 public TileInfo()
 {
     BoundingSphere = new BBSphere();
 }