public SilverLiningMatrix3 Transpose() { SilverLiningMatrix3 mout = new SilverLiningMatrix3(); for (int row = 0; row < 3; row++) { for (int col = 0; col < 3; col++) { mout.elem[row, col] = elem[col, row]; } } return(mout); }
public static SilverLiningMatrix3 operator *(SilverLiningMatrix3 m1, SilverLiningMatrix3 m2) { SilverLiningMatrix3 mout = new SilverLiningMatrix3(); for (int row = 0; row < 3; row++) { for (int col = 0; col < 3; col++) { mout.elem[row, col] = m1.elem[row, 0] * m2.elem[0, col] + m1.elem[row, 1] * m2.elem[1, col] + m1.elem[row, 2] * m2.elem[2, col]; } } return(mout); }
public void FromXYZ (double Rx, double Ry, double Rz) { SilverLiningMatrix3 rx, ry, rz; rx = new SilverLiningMatrix3 (); ry = new SilverLiningMatrix3 (); rz = new SilverLiningMatrix3 (); rx.FromRx (Rx); ry.FromRy (Ry); rz.FromRz (Rz); SilverLiningMatrix3 result = rx * (ry * rz); elem = result.elem; }
public void FromXYZ(double Rx, double Ry, double Rz) { SilverLiningMatrix3 rx, ry, rz; rx = new SilverLiningMatrix3(); ry = new SilverLiningMatrix3(); rz = new SilverLiningMatrix3(); rx.FromRx(Rx); ry.FromRy(Ry); rz.FromRz(Rz); SilverLiningMatrix3 result = rx * (ry * rz); elem = result.elem; }
public SilverLiningSky () { sunDistance *= (float)SilverLining.unitScale; moonDistance *= (float)SilverLining.unitScale; H *= (float)SilverLining.unitScale; ephemeris = new SilverLiningEphemeris (); InitTwilightLuminances (); sunSpectrum = new SilverLiningSolarSpectrum (); lunarSpectrum = new SilverLiningLunarSpectrum (); XYZ2RGB = new SilverLiningMatrix3 (3.240479, -0.969256, 0.055648, -1.537150, 1.875992, -0.204043, -0.498535, 0.041556, 1.057311); XYZ2RGB4 = new Matrix4x4 (); XYZ2RGB4[0, 0] = 3.240479f; XYZ2RGB4[0, 1] = -0.969256f; XYZ2RGB4[0, 2] = 0.055648f; XYZ2RGB4[0, 3] = 0.0f; XYZ2RGB4[1, 0] = -1.537150f; XYZ2RGB4[1, 1] = 1.875992f; XYZ2RGB4[1, 2] = -0.204043f; XYZ2RGB4[1, 3] = 0.0f; XYZ2RGB4[2, 0] = -0.498535f; XYZ2RGB4[2, 1] = 0.041556f; XYZ2RGB4[2, 2] = 1.057311f; XYZ2RGB4[2, 3] = 0.0f; XYZ2RGB4[3, 0] = 0.0f; XYZ2RGB4[3, 1] = 0.0f; XYZ2RGB4[3, 2] = 0.0f; XYZ2RGB4[3, 3] = 1.0f; hosekWilkieRadiances = new double[3]; hosekWilkieCoeffs = new double[3,9]; datasetsXYZ = new double[][] { datasetXYZ1, datasetXYZ2, datasetXYZ3 }; datasetsXYZRad = new double[][] { datasetXYZRad1, datasetXYZRad2, datasetXYZRad3 }; }
public SilverLiningEphemeris () { equatorialToHorizon = new SilverLiningMatrix3 (); eclipticToHorizon = new SilverLiningMatrix3 (); eclipticToEquatorial = new SilverLiningMatrix3 (); equatorialToGeographic = new SilverLiningMatrix3 (); horizonToEquatorial = new SilverLiningMatrix3 (); horizonToGeographic = new SilverLiningMatrix3 (); geographicToEquatorial = new SilverLiningMatrix3 (); geographicToHorizon = new SilverLiningMatrix3 (); precession = new SilverLiningMatrix3 (); moonEq = new Vector3 (); sunEq = new Vector3 (); moonEcl = new Vector3 (); sunEcl = new Vector3 (); sunHoriz = new Vector3 (); moonHoriz = new Vector3 (); moonGeo = new Vector3 (); sunGeo = new Vector3 (); geoZUp = true; lastLocation = new SilverLiningLocation (); lastTime = new SilverLiningTime (); planets = new Planet[(int)Planets.NUM_PLANETS]; planetElements = new OrbitalElements[(int)Planets.NUM_PLANETS]; // Mercury planetElements[0] = new OrbitalElements (0.240852, RADIANS (60.750646), RADIANS (77.299833), 0.205633, 0.387099, RADIANS (7.004540), RADIANS (48.212740), 6.74, -0.42); // Venus planetElements[1] = new OrbitalElements (0.615211, RADIANS (88.455855), RADIANS (131.430236), 0.006778, 0.723332, RADIANS (3.394535), RADIANS (76.589820), 16.92, -4.40); // Earth planetElements[2] = new OrbitalElements (1.00004, RADIANS (99.403308), RADIANS (102.768413), 0.016713, 1.00000, 0, 0, 0, 0); // Mars planetElements[3] = new OrbitalElements (1.880932, RADIANS (240.739474), RADIANS (335.874939), 0.093396, 1.523688, RADIANS (1.849736), RADIANS (49.480308), 9.36, -1.52); // Jupiter planetElements[4] = new OrbitalElements (11.863075, RADIANS (90.638185), RADIANS (14.170747), 0.048482, 5.202561, RADIANS (1.303613), RADIANS (100.353142), 196.74, -9.40); // Saturn planetElements[5] = new OrbitalElements (29.471362, RADIANS (287.690033), RADIANS (92.861407), 0.055581, 9.554747, RADIANS (2.488980), RADIANS (113.576139), 165.60, -8.88); }
public SilverLiningEphemeris() { equatorialToHorizon = new SilverLiningMatrix3(); eclipticToHorizon = new SilverLiningMatrix3(); eclipticToEquatorial = new SilverLiningMatrix3(); equatorialToGeographic = new SilverLiningMatrix3(); horizonToEquatorial = new SilverLiningMatrix3(); horizonToGeographic = new SilverLiningMatrix3(); geographicToEquatorial = new SilverLiningMatrix3(); geographicToHorizon = new SilverLiningMatrix3(); precession = new SilverLiningMatrix3(); moonEq = new Vector3(); sunEq = new Vector3(); moonEcl = new Vector3(); sunEcl = new Vector3(); sunHoriz = new Vector3(); moonHoriz = new Vector3(); moonGeo = new Vector3(); sunGeo = new Vector3(); geoZUp = true; lastLocation = new SilverLiningLocation(); lastTime = new SilverLiningTime(); planets = new Planet[(int)Planets.NUM_PLANETS]; planetElements = new OrbitalElements[(int)Planets.NUM_PLANETS]; // Mercury planetElements[0] = new OrbitalElements(0.240852, RADIANS(60.750646), RADIANS(77.299833), 0.205633, 0.387099, RADIANS(7.004540), RADIANS(48.212740), 6.74, -0.42); // Venus planetElements[1] = new OrbitalElements(0.615211, RADIANS(88.455855), RADIANS(131.430236), 0.006778, 0.723332, RADIANS(3.394535), RADIANS(76.589820), 16.92, -4.40); // Earth planetElements[2] = new OrbitalElements(1.00004, RADIANS(99.403308), RADIANS(102.768413), 0.016713, 1.00000, 0, 0, 0, 0); // Mars planetElements[3] = new OrbitalElements(1.880932, RADIANS(240.739474), RADIANS(335.874939), 0.093396, 1.523688, RADIANS(1.849736), RADIANS(49.480308), 9.36, -1.52); // Jupiter planetElements[4] = new OrbitalElements(11.863075, RADIANS(90.638185), RADIANS(14.170747), 0.048482, 5.202561, RADIANS(1.303613), RADIANS(100.353142), 196.74, -9.40); // Saturn planetElements[5] = new OrbitalElements(29.471362, RADIANS(287.690033), RADIANS(92.861407), 0.055581, 9.554747, RADIANS(2.488980), RADIANS(113.576139), 165.60, -8.88); }
public void Update(SilverLiningTime time, SilverLiningLocation location) { bool timeChanged = false; bool locationChanged = false; if (time != lastTime) { timeChanged = true; lastTime = new SilverLiningTime(time); } if (location != lastLocation) { locationChanged = true; lastLocation = new SilverLiningLocation(location); } if (timeChanged || locationChanged) { T = time.GetEpoch2000Centuries(true); Tuncorr = time.GetEpoch2000Centuries(false); epochDays = time.GetEpoch1990Days(false); SilverLiningMatrix3 Rx, Ry, Rz; Rx = new SilverLiningMatrix3(); Ry = new SilverLiningMatrix3(); Rz = new SilverLiningMatrix3(); Rx.FromRx(-0.1118 * T); Ry.FromRy(0.00972 * T); Rz.FromRz(-0.01118 * T); precession = Rz * (Ry * Rx); GMST = 4.894961 + 230121.675315 * Tuncorr; // radians LMST = GMST + RADIANS(location.GetLongitude()); // radians double latitude = RADIANS(location.GetLatitude()); e = 0.409093 - 0.000227 * T; Ry.FromRy(-(latitude - PI / 2.0)); Rz.FromRz(LMST); Rx.FromRx(-e); equatorialToHorizon = Ry * Rz * precession; eclipticToHorizon = Ry * Rz * Rx * precession; eclipticToEquatorial = Rx; equatorialToGeographic.FromRz(GMST); geographicToEquatorial = equatorialToGeographic.Transpose(); horizonToEquatorial = equatorialToHorizon.Transpose(); horizonToGeographic = equatorialToGeographic * horizonToEquatorial; geographicToHorizon = equatorialToHorizon * geographicToEquatorial; ComputeSunPosition(); ComputeMoonPosition(); ComputeEarthPosition(); ComputeMoonPositionAngle(); for (int i = 0; i < (int)Planets.NUM_PLANETS; i++) { if (i != (int)Planets.EARTH) { ComputePlanetPosition(i); } } } }
public void Update (SilverLiningTime time, SilverLiningLocation location) { bool timeChanged = false; bool locationChanged = false; if (time != lastTime) { timeChanged = true; lastTime = new SilverLiningTime (time); } if (location != lastLocation) { locationChanged = true; lastLocation = new SilverLiningLocation (location); } if (timeChanged || locationChanged) { T = time.GetEpoch2000Centuries (true); Tuncorr = time.GetEpoch2000Centuries (false); epochDays = time.GetEpoch1990Days (false); SilverLiningMatrix3 Rx, Ry, Rz; Rx = new SilverLiningMatrix3 (); Ry = new SilverLiningMatrix3 (); Rz = new SilverLiningMatrix3 (); Rx.FromRx (-0.1118 * T); Ry.FromRy (0.00972 * T); Rz.FromRz (-0.01118 * T); precession = Rz * (Ry * Rx); GMST = 4.894961 + 230121.675315 * Tuncorr; // radians LMST = GMST + RADIANS (location.GetLongitude ()); // radians double latitude = RADIANS (location.GetLatitude ()); e = 0.409093 - 0.000227 * T; Ry.FromRy (-(latitude - PI / 2.0)); Rz.FromRz (LMST); Rx.FromRx (-e); equatorialToHorizon = Ry * Rz * precession; eclipticToHorizon = Ry * Rz * Rx * precession; eclipticToEquatorial = Rx; equatorialToGeographic.FromRz (GMST); geographicToEquatorial = equatorialToGeographic.Transpose (); horizonToEquatorial = equatorialToHorizon.Transpose (); horizonToGeographic = equatorialToGeographic * horizonToEquatorial; geographicToHorizon = equatorialToHorizon * geographicToEquatorial; ComputeSunPosition (); ComputeMoonPosition (); ComputeEarthPosition (); ComputeMoonPositionAngle (); for (int i = 0; i < (int)Planets.NUM_PLANETS; i++) { if (i != (int)Planets.EARTH) { ComputePlanetPosition (i); } } } }
public SilverLiningSky() { sunDistance *= (float)SilverLining.unitScale; moonDistance *= (float)SilverLining.unitScale; H *= (float)SilverLining.unitScale; ephemeris = new SilverLiningEphemeris (); InitTwilightLuminances (); sunSpectrum = new SilverLiningSolarSpectrum (); lunarSpectrum = new SilverLiningLunarSpectrum (); XYZ2RGB = new SilverLiningMatrix3 (3.240479, -0.969256, 0.055648, -1.537150, 1.875992, -0.204043, -0.498535, 0.041556, 1.057311); XYZ2RGB4 = new Matrix4x4 (); XYZ2RGB4[0, 0] = 3.240479f; XYZ2RGB4[0, 1] = -0.969256f; XYZ2RGB4[0, 2] = 0.055648f; XYZ2RGB4[0, 3] = 0.0f; XYZ2RGB4[1, 0] = -1.537150f; XYZ2RGB4[1, 1] = 1.875992f; XYZ2RGB4[1, 2] = -0.204043f; XYZ2RGB4[1, 3] = 0.0f; XYZ2RGB4[2, 0] = -0.498535f; XYZ2RGB4[2, 1] = 0.041556f; XYZ2RGB4[2, 2] = 1.057311f; XYZ2RGB4[2, 3] = 0.0f; XYZ2RGB4[3, 0] = 0.0f; XYZ2RGB4[3, 1] = 0.0f; XYZ2RGB4[3, 2] = 0.0f; XYZ2RGB4[3, 3] = 1.0f; }
public SilverLiningMatrix3 Transpose () { SilverLiningMatrix3 mout = new SilverLiningMatrix3 (); for (int row = 0; row < 3; row++) { for (int col = 0; col < 3; col++) { mout.elem[row, col] = elem[col, row]; } } return mout; }
public static SilverLiningMatrix3 operator * (SilverLiningMatrix3 m1, SilverLiningMatrix3 m2) { SilverLiningMatrix3 mout = new SilverLiningMatrix3 (); for (int row = 0; row < 3; row++) { for (int col = 0; col < 3; col++) { mout.elem[row, col] = m1.elem[row, 0] * m2.elem[0, col] + m1.elem[row, 1] * m2.elem[1, col] + m1.elem[row, 2] * m2.elem[2, col]; } } return mout; }