public double Angle(Coordinates pointB) { double y = this.Lat; double x = this.Lng * Math.Cos(y * RC); double y1 = pointB.Lat; double x1 = pointB.Lng * Math.Cos(y1 * RC); return Math.Atan2((y1 - y), (x1 - x)); }
public static Coordinates HorizonToEquitorial(Coordinates altAz, Coordinates location, Date utc) { double hourAngle = MstFromUTC2(utc, location.Lng);// -(equitorial.RA * 15); double haLocal; double declination; Vector2d raDec = AltAzToRaDec(altAz.Alt * RC, altAz.Az * RC, location.Lat * RC); haLocal = raDec.X; declination = raDec.Y; double ha = (haLocal / RC); hourAngle += ha; if (hourAngle < 0) { hourAngle += 360.00; } if (hourAngle > 360) { hourAngle -= 360; } return Coordinates.FromRaDec(hourAngle / 15, declination / RC); }
public static Vector3d RADecTo3dPointRad(Coordinates point, double radius) { point.Dec = -point.Dec; return Vector3d.Create((Math.Cos(point.RA * RCRA) * Math.Cos(point.Dec * RC) * radius), (Math.Sin(point.Dec * RC) * radius), (Math.Sin(point.RA * RCRA) * Math.Cos(point.Dec * RC) * radius)); }
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 static Coordinates EquitorialToHorizon(Coordinates equitorial, Coordinates location, Date utc) { double hourAngle = MstFromUTC2(utc, location.Lng) - (equitorial.RA * 15); if (hourAngle < 0) { hourAngle += 360.00; } double ha = hourAngle * RC; double dec = equitorial.Dec * RC; double lat = (location.Lat) * RC; double sinAlt = Math.Sin(dec) * Math.Sin(lat) + Math.Cos(dec) * Math.Cos(lat) * Math.Cos(ha); double altitude = Math.Asin(sinAlt); double cosAzimith = (Math.Sin(dec) - Math.Sin(altitude) * Math.Sin(lat)) / (Math.Cos(altitude) * Math.Cos(lat)); double azimuth = Math.Acos(cosAzimith); Coordinates altAz = new Coordinates(azimuth, altitude); if (Math.Sin(ha) > 0) { altAz.Az = (360 - altAz.Az); } return altAz; }
public virtual Place FindClosest(Coordinates target, float distance, Place closestPlace, bool astronomical) { return closestPlace; }
//static public Coordinates EquitorialToHorizon4(Coordinates equitorial, Coordinates location, Date utc) //{ // double lon = location.Lng; // double hour = utc.GetHours() + utc.GetMinutes() / 60.00 + utc.GetSeconds() / 3600.0 + utc.GetMilliseconds() / 3600000.0; // double day = utc.GetDate() + hour / 24.0; // double fullDays = Math.Floor(day); // int month = utc.GetMonth(); // int year = utc.GetFullYear(); // if (month < 3) // { // year--; // month += 12; // } // double gr; // if (year + month / 100 + fullDays / 10000 >= 1582.1015) // { // gr = 2 - Math.Floor(year / 100.0) + Math.Floor(Math.Floor(year / 100.0) / 4); // } // else // { // gr = 0; // } // double julianDay = Math.Floor(365.25 * year) + Math.Floor(30.6001 * (month + 1)) + fullDays + 1720994.5 + gr; // double julianDay2 = julianDay + hour / 24; // double t = (julianDay - 2415020) / 36525; // double ss1 = 6.6460656 + 2400.051 * t + 0.00002581 * t * t; // double st = (ss1 / 24 - Math.Floor(ss1 / 24)) * 24; // double gsth = Math.Floor(st); // double gstm = Math.Floor((st - Math.Floor(st)) * 60); // double gsts = ((st - Math.Floor(st)) * 60 - gstm) * 60; // double sa = st + (day - Math.Floor(day)) * 24 * 1.002737908; // sa = sa + (lon / 15); // if (sa < 0) // { // sa += 24; // } // if (sa > 24) // { // sa -= 24; // } // double tsh = Math.Floor(sa); // double tsm = Math.Floor((sa - Math.Floor(sa)) * 60); // double tss = ((sa - Math.Floor(sa)) * 60 - tsm) * 60; // return new Coordinates(0, 0); //} public double Distance(Coordinates pointB) { double y = this.Lat; double x = this.Lng * Math.Cos(y * RC); double y1 = pointB.Lat; double x1 = pointB.Lng * Math.Cos(y1 * RC); return Math.Sqrt((y - y1) * (y - y1) + (x - x1) * (x - x1)); }
public static bool DrawAltAzGrid(RenderContext renderContext, float opacity, Color drawColor) { Coordinates zenithAltAz = new Coordinates(0, 0); Coordinates zenith = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now); double raPart = -((zenith.RA + 6) / 24.0 * (Math.PI * 2)); double decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2)); string raText = Coordinates.FormatDMS(zenith.RA); Matrix3d mat = Matrix3d.RotationY((float)-raPart); mat.Multiply(Matrix3d.RotationX((float)decPart)); mat.Invert(); if (altAzLineList == null) { altAzLineList = new SimpleLineList(); altAzLineList.DepthBuffered = false; for (double l = 0; l < 360; l += 10) { for (double b = -80; b < 80; b += 2) { altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15 , b, 1), Coordinates.RADecTo3dAu(l / 15 , b + 2, 1)); } } for (double b = -80; b <= 80; b += 10) { for (double l = 0; l < 360; l += 5) { altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15 , b, 1), Coordinates.RADecTo3dAu((l + 5) / 15 , b, 1)); } } int counter = 0; for (double l = 0; l < 360; l += 1) { double b = 0.25; switch (counter % 10) { case 0: counter++; continue; case 5: b = .5; break; } counter++; altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15 , b, 1), Coordinates.RADecTo3dAu(l / 15, -b, 1)); } counter = 0; for (double l = 0; l < 360; l += 90) { counter = 0; for (double b = -80; b <= 80; b += 1) { double width = 0.5 / 2; switch (counter % 10) { case 0: counter++; continue; case 5: width = .5; break; } counter++; altAzLineList.AddLine(Coordinates.RADecTo3dAu((l + width) / 15 , b, 1), Coordinates.RADecTo3dAu((l - width) / 15 , b, 1)); } } } Matrix3d matOldWorld = renderContext.World.Clone(); Matrix3d matOldWorldBase = renderContext.WorldBase.Clone(); renderContext.WorldBase = Matrix3d.MultiplyMatrix(mat, renderContext.World); renderContext.World = renderContext.WorldBase.Clone(); renderContext.MakeFrustum(); altAzLineList.ViewTransform = Matrix3d.InvertMatrix(mat); altAzLineList.DrawLines(renderContext, opacity, drawColor); renderContext.WorldBase = matOldWorldBase; renderContext.World = matOldWorld; renderContext.MakeFrustum(); return true; }
public static bool DrawAltAzGridText(RenderContext renderContext, float opacity, Color drawColor) { Coordinates zenithAltAz = new Coordinates(0, 0); Coordinates zenith = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now); double raPart = -((zenith.RA -6) / 24.0 * (Math.PI * 2)); double decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2)); string raText = Coordinates.FormatDMS(zenith.RA); Matrix3d mat = Matrix3d.RotationY((float)-raPart - Math.PI); mat.Multiply(Matrix3d.RotationX((float)decPart)); mat.Invert(); MakeAltAzGridText(); Matrix3d matOldWorld = renderContext.World.Clone(); Matrix3d matOldWorldBase = renderContext.WorldBase.Clone(); renderContext.WorldBase = Matrix3d.MultiplyMatrix(mat, renderContext.World); renderContext.World = renderContext.WorldBase.Clone(); renderContext.MakeFrustum(); AltAzTextBatch.ViewTransform = Matrix3d.InvertMatrix(mat); AltAzTextBatch.Draw(renderContext, opacity, drawColor); renderContext.WorldBase = matOldWorldBase; renderContext.World = matOldWorld; renderContext.MakeFrustum(); return true; }
public static Matrix3d GetMapMatrix(Coordinates center, double fieldWidth, double fieldHeight, double rotation) { double offsetX = 0; double offsetY = 0; offsetX = -(((center.Lng + 180 - (fieldWidth / 2)) / 360)); offsetY = -((1 - ((center.Lat + 90 + (fieldHeight / 2)) / 180))); Matrix2d mat = new Matrix2d(); double scaleX = 0; double scaleY = 0; scaleX = 360 / fieldWidth; scaleY = 180 / fieldHeight; mat = Matrix2d.Multiply(mat, Matrix2d.Translation(offsetX, offsetY)); mat = Matrix2d.Multiply(mat, Matrix2d.Scaling(scaleX, scaleY)); if (rotation != 0) { mat = Matrix2d.Multiply(mat,Matrix2d.Translation(-.5, -.5)); mat = Matrix2d.Multiply(mat,Matrix2d.Rotation(rotation)); mat = Matrix2d.Multiply(mat,Matrix2d.Translation(.5, .5)); } return Matrix3d.FromMatrix2d(mat); }
public virtual Place FindClosest(Coordinates target, float distance, Place closestPlace, bool astronomical) { return(closestPlace); }
public void SetupMatricesSpace3d(double canvasWidth, double canvasHeight) { Lighting = false; if (!firstTimeInit) { galacticMatrix = Matrix3d.Identity; // -28.9361739586894, 17.7603329867975 galacticMatrix.Multiply(Matrix3d.RotationY(-(270-(17.7603329867975*15 )) / 180.0 * Math.PI)); galacticMatrix.Multiply(Matrix3d.RotationX(-((-28.9361739586894)) / 180.0 * Math.PI)); galacticMatrix.Multiply(Matrix3d.RotationZ(((31.422052860102041270114993238783)-90) / 180.0 * Math.PI)); //galacticMatrix.Transpose(); //galacticMatrix.Invert(); firstTimeInit = true; } Space = true; RenderTriangle.CullInside = true; Matrix3d WorldMatrix = Matrix3d.Identity; if (Settings.Active.GalacticMode) { WorldMatrix.Multiply(galacticMatrix); WorldMatrix.Multiply(Matrix3d.RotationY(((az )) / 180.0 * Math.PI)); WorldMatrix.Multiply(Matrix3d.RotationX(-((alt)) / 180.0 * Math.PI)); double[] gPoint = Coordinates.GalactictoJ2000(az, alt); viewPoint = Coordinates.RADecTo3dAu(gPoint[0]/15, gPoint[1], 1.0); TargetCamera.Lng = this.RAtoViewLng(gPoint[0] / 15); TargetCamera.Lat = gPoint[1]; ViewCamera.Lat = TargetCamera.Lat; ViewCamera.Lng = TargetCamera.Lng; } else { WorldMatrix.Multiply(Matrix3d.RotationY(-((ViewCamera.Lng -90 )) / 180.0 * Math.PI)); WorldMatrix.Multiply(Matrix3d.RotationX(-((ViewCamera.Lat)) / 180.0 * Math.PI)); viewPoint = Coordinates.RADecTo3dAu(RA, Dec, 1.0); } double camLocal = ((ViewCamera.Rotation /*+ 90*/)); fovAngle = ((this.ViewCamera.Zoom) / FOVMULT) / Math.PI * 180; fovScale = (fovAngle / canvasHeight) * 3600; //Settings.Global.LocalHorizonMode = true; // altaz if (Settings.Active.LocalHorizonMode && backgroundImageset.DataSetType == ImageSetType.Sky) { Coordinates zenithAltAz = new Coordinates(0, 0); zenithAltAz.Az = 0; zenithAltAz.Alt = 0; Coordinates zenith = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now); //Coordinates zenith2 = Coordinates.HorizonToEquitorial(zenithAltAz, Coordinates.FromLatLng(1, 1), SpaceTimeController.Now); //Coordinates zenith3 = Coordinates.HorizonToEquitorial(zenithAltAz, Coordinates.FromLatLng(-1, 1), SpaceTimeController.Now); double raPart = -((zenith.RA - 6) / 24.0 * (Math.PI * 2)); double decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2)); string raText = Coordinates.FormatDMS(zenith.RA); WorldMatrix = Matrix3d.RotationY(-raPart-Math.PI); WorldMatrix.Multiply(Matrix3d.RotationX(decPart)); if (SpaceTimeController.Location.Lat < 0) { WorldMatrix.Multiply(Matrix3d.RotationY(((az) / 180.0 * Math.PI))); WorldMatrix.Multiply(Matrix3d.RotationX(((alt) / 180.0 * Math.PI))); camLocal += Math.PI; } else { WorldMatrix.Multiply(Matrix3d.RotationY(((-az) / 180.0 * Math.PI))); WorldMatrix.Multiply(Matrix3d.RotationX(((-alt) / 180.0 * Math.PI))); } Coordinates currentRaDec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now); ViewCamera.Lat = TargetCamera.Lat = currentRaDec.Dec; ViewCamera.Lng = TargetCamera.Lng = RAtoViewLng(currentRaDec.RA); } World = WorldMatrix; WorldBase = WorldMatrix.Clone(); // altaz double localZoomFactor = ViewCamera.Zoom; double FovAngle = ((localZoomFactor) / FOVMULT) / Math.PI * 180; CameraPosition = Vector3d.Create(0.0, 0.0, 0.0); // This is for distance Calculation. For space everything is the same distance, so camera target is key. View = Matrix3d.LookAtLH(CameraPosition, Vector3d.Create(0.0, 0.0, -1.0), Vector3d.Create(Math.Sin(camLocal), Math.Cos(camLocal), 0.0)); ViewBase = View.Clone(); double m_nearPlane = .1; nearPlane = .1f; Projection = Matrix3d.PerspectiveFovLH((localZoomFactor) / FOVMULT, (double)canvasWidth / (double)canvasHeight, .1, -2.0); SetMatrixes(); MakeFrustum(); }