/// <summary> /// Transforms the corners of this node to world space /// </summary> /// <returns></returns> protected virtual Vector3D[] transformCorners() { Vector3D[] transformed = new Vector3D[4]; Vector3D[] cartesianCorners = corners.Select(latlon => RenderWGS84.ToWorld(latlon.Latitude, latlon.Longitude)).ToArray(); for (int i = 0; i < cartesianCorners.Length; i++) { Vector3D normalized; Vector3D.Normalize(ref cartesianCorners[i], out normalized); transformed[i] = normalized * RenderWGS84.EarthRadius; } return(transformed); }
public TerrainNode(TerrainNode parent, Quadrant quad, LatLon bl, LatLon tl, LatLon tr, LatLon br) { Parent = parent; Quadrant = quad; corners = new LatLon[4] { bl, tl, tr, br }; latLonExtents = new Extent(BL.Longitude, BL.Latitude, TR.Longitude, TR.Latitude); var mercBL = RenderWGS84.ToGoogleBing(BL.Longitude, BL.Latitude); var mercTR = RenderWGS84.ToGoogleBing(TR.Longitude, TR.Latitude); meterExtents = new Extent(mercBL.X, mercBL.Y, mercTR.X, mercTR.Y); center = LatLon.Average(corners); splitDepth = 0; Vector3D[] transformed = transformCorners(); this.aabb = BoundingBox.FromPoints(transformed.Select(vec => vec.ToVector3()).ToArray()); generateSplitBox(); }