public double GetEarthAltitude(double ViewLat, double ViewLong, bool meters) { if (WWTControl.Singleton.SolarSystemMode) { Vector3d pnt = Coordinates.GeoTo3dDouble(ViewLat, ViewLong + 90); Matrix3d EarthMat = Planets.EarthMatrixInv; pnt = Vector3d.TransformCoordinate(pnt, EarthMat); pnt.Normalize(); Vector2d point = Coordinates.CartesianToLatLng(pnt); return(GetAltitudeForLatLongForPlanet((int)ViewCamera.Target, point.Y, point.X)); } else if (BackgroundImageset.DataSetType == ImageSetType.Earth) { return(meters ? GetMetersAltitudeForLatLong(ViewLat, ViewLong) : GetScaledAltitudeForLatLong(ViewLat, ViewLong)); } //else if (RenderContext.BackgroundImageset.DataSetType == ImageSetType.Planet) //{ // return GetAltitudeForLatLong(ViewLat, ViewLong); //} else { return(0); } }
private double GetAltitudeFromLatLng(double lat, double lng, bool meters) { Vector3d testPoint = Coordinates.GeoTo3dDouble(lat, lng); Vector2d uv = DistanceCalc.GetUVFromInnerPoint(TopLeft, TopRight, BottomLeft, BottomRight, testPoint); // Get 4 samples and interpolate double uud = Math.Max(0, Math.Min(16, (uv.X * 16))); double vvd = Math.Max(0, Math.Min(16, (uv.Y * 16))); int uu = Math.Max(0, Math.Min(15, (int)(uv.X * 16))); int vv = Math.Max(0, Math.Min(15, (int)(uv.Y * 16))); double ha = uud - uu; double va = vvd - vv; if (demArray != null) { // 4 nearest neighbors double ul = demArray[uu + 17 * vv]; double ur = demArray[(uu + 1) + 17 * vv]; double ll = demArray[uu + 17 * (vv + 1)]; double lr = demArray[(uu + 1) + 17 * (vv + 1)]; double top = ul * (1 - ha) + ha * ur; double bottom = ll * (1 - ha) + ha * lr; double val = top * (1 - va) + va * bottom; return(val / (meters ? 1 : DemScaleFactor)); } return(demAverage / (meters ? 1 : DemScaleFactor)); }
private void InitializeRoute(RenderContext renderContext) { triangleList = new TriangleList(); triangleList.Decay = 1000; triangleList.Sky = this.Astronomical; triangleList.TimeSeries = true; triangleList.DepthBuffered = false; triangleList.AutoTime = false; int steps = 500; Vector3d start = Coordinates.GeoTo3dDouble(latStart, lngStart); Vector3d end = Coordinates.GeoTo3dDouble(latEnd, lngEnd); Vector3d dir = Vector3d.SubtractVectors(end, start); dir.Normalize(); Vector3d startNormal = start; startNormal.Normalize(); Vector3d left = Vector3d.Cross(startNormal, dir); Vector3d right = Vector3d.Cross(dir, startNormal); left.Normalize(); right.Normalize(); left.Multiply(.001 * width); right.Multiply(.001 * width); Vector3d lastLeft = new Vector3d(); Vector3d lastRight = new Vector3d(); bool firstTime = true; for (int i = 0; i <= steps; i++) { Vector3d v = Vector3d.Lerp(start, end, i / (float)steps); v.Normalize(); // v.Multiply(1.1); Vector3d cl = v; Vector3d cr = v; cl.Add(left); cr.Add(right); if (!firstTime) { triangleList.AddQuad(lastRight, lastLeft, cr, cl, Color, new Dates(i / (float)steps, 2)); } else { firstTime = false; } lastLeft = cl; lastRight = cr; } }
public double Distance3d(Coordinates pointB) { Vector3d pnt1 = Coordinates.GeoTo3dDouble(pointB.Lat, pointB.Lng); Vector3d pnt2 = Coordinates.GeoTo3dDouble(this.Lat, this.Lng); Vector3d pntDiff = Vector3d.SubtractVectors(pnt1, pnt2); return(pntDiff.Length() / RC); }
public override bool IsPointInTile(double lat, double lng) { if (Level == 0) { return(true); } if (Level == 1) { if ((lng >= 0 && lng <= 90) && (tileX == 0 && tileY == 1)) { return(true); } if ((lng > 90 && lng <= 180) && (tileX == 1 && tileY == 1)) { return(true); } if ((lng < 0 && lng >= -90) && (tileX == 0 && tileY == 0)) { return(true); } if ((lng < -90 && lng >= -180) && (tileX == 1 && tileY == 0)) { return(true); } return(false); } if (!this.DemReady || this.DemData == null) { return(false); } Vector3d testPoint = Coordinates.GeoTo3dDouble(-lat, lng); bool top = IsLeftOfHalfSpace(TopLeft.Copy(), TopRight.Copy(), testPoint); bool right = IsLeftOfHalfSpace(TopRight.Copy(), BottomRight.Copy(), testPoint); bool bottom = IsLeftOfHalfSpace(BottomRight.Copy(), BottomLeft.Copy(), testPoint); bool left = IsLeftOfHalfSpace(BottomLeft.Copy(), TopLeft.Copy(), testPoint); if (top && right && bottom && left) { // showSelected = true; return(true); } return(false);; }
public override bool IsPointInTile(double lat, double lng) { if (Level == 0) { return(true); } if (Level == 1) { if ((lng >= 0 && lng <= 90) && (tileX == 0 && tileY == 1)) { return(true); } if ((lng > 90 && lng <= 180) && (tileX == 1 && tileY == 1)) { return(true); } if ((lng < 0 && lng >= -90) && (tileX == 0 && tileY == 0)) { return(true); } if ((lng < -90 && lng >= -180) && (tileX == 1 && tileY == 0)) { return(true); } } Vector3d testPoint = Coordinates.GeoTo3dDouble(lat, lng); bool top = IsLeftOfHalfSpace(TopLeft, TopRight, testPoint); bool right = IsLeftOfHalfSpace(TopRight, BottomRight, testPoint); bool bottom = IsLeftOfHalfSpace(BottomRight, BottomLeft, testPoint); bool left = IsLeftOfHalfSpace(BottomLeft, TopLeft, testPoint); if (top && right && bottom && left) { return(true); } return(false);; }
public static CameraParameters InterpolateGreatCircle(CameraParameters from, CameraParameters to, double alphaIn, InterpolationType type, bool fastDirectionMove) { CameraParameters result = new CameraParameters(); double alpha = EaseCurve(alphaIn, type); double alphaBIn = Math.Min(1.0, alphaIn * 2); double alphaB = EaseCurve(alphaBIn, type); result.Angle = to.Angle * alpha + from.Angle * (1.0 - alpha); result.Rotation = to.Rotation * alpha + from.Rotation * (1.0 - alpha); Vector3d left = Coordinates.GeoTo3dDouble(from.Lat, from.Lng); Vector3d right = Coordinates.GeoTo3dDouble(to.Lat, to.Lng); Vector3d mid = Vector3d.Slerp(left, right, alpha); Vector2d midV2 = Coordinates.CartesianToLatLng(mid); result.Lat = midV2.Y; result.Lng = midV2.X; result.Zoom = Math.Pow(2, LogN(to.Zoom, 2) * alpha + LogN(from.Zoom, 2) * (1.0 - alpha)); result.Opacity = (double)(to.Opacity * alpha + from.Opacity * (1.0 - alpha)); result.ViewTarget = Vector3d.Lerp(from.ViewTarget, to.ViewTarget, alpha); result.TargetReferenceFrame = to.TargetReferenceFrame; if (to.Target == from.Target) { result.Target = to.Target; } else { result.Target = SolarSystemObjects.Custom; } return(result); }
public override double GetSurfacePointAltitude(double lat, double lng, bool meters) { if (Level < lastDeepestLevel) { //interate children for (int ii = 0; ii < 4; ii++) { Tile child = children[ii]; if (child != null) { if (child.IsPointInTile(lat, lng)) { double retVal = child.GetSurfacePointAltitude(lat, lng, meters); if (retVal != 0) { return(retVal); } else { break; } } } } } TileTargetLevel = Level; TileTargetX = tileX; TileTargetY = tileY; Vector3d testPoint = Coordinates.GeoTo3dDouble(-lat, lng); testPoint = Vector3d.SubtractVectors(new Vector3d(), testPoint); Vector2d uv = DistanceCalc.GetUVFromInnerPoint(TopLeft.Copy(), TopRight.Copy(), BottomLeft.Copy(), BottomRight.Copy(), testPoint.Copy()); //Document.Title = "u:" + uv.X + ", v:" + uv.Y; //uv.X = 1 - uv.X; //uv.Y = 1 - uv.Y; // Get 4 samples and interpolate double uud = Math.Max(0, Math.Min(16, (uv.X * 16))); double vvd = Math.Max(0, Math.Min(16, (uv.Y * 16))); int uu = Math.Max(0, Math.Min(15, (int)(uv.X * 16))); int vv = Math.Max(0, Math.Min(15, (int)(uv.Y * 16))); double ha = uud - uu; double va = vvd - vv; if (demArray != null) { // 4 nearest neighbors double ul = demArray[uu + 17 * vv]; double ur = demArray[(uu + 1) + 17 * vv]; double ll = demArray[uu + 17 * (vv + 1)]; double lr = demArray[(uu + 1) + 17 * (vv + 1)]; double top = ul * (1 - ha) + ha * ur; double bottom = ll * (1 - ha) + ha * lr; double val = top * (1 - va) + va * bottom; return(val / DemScaleFactor); } return(demAverage / DemScaleFactor); }