Skip to content

Commit

Permalink
added geomagnetic_offset to radiation models
Browse files Browse the repository at this point in the history
  • Loading branch information
SirMortimer committed Jun 11, 2019
1 parent afb971e commit d6e92e7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Kerbalism/Radiation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public RadiationBody(ConfigNode node, Dictionary<string, RadiationModel> models,
radiation_pause = Lib.ConfigValue(node, "radiation_pause", 0.0) / 3600.0;
geomagnetic_pole_lat = Lib.ConfigValue(node, "geomagnetic_pole_lat", 90.0f);
geomagnetic_pole_lon = Lib.ConfigValue(node, "geomagnetic_pole_lon", 0.0f);
geomagnetic_offset = Lib.ConfigValue(node, "geomagnetic_offset", 0.0f);
reference = Lib.ConfigValue(node, "reference", 0);

// get the radiation environment
Expand All @@ -191,7 +192,7 @@ public RadiationBody(ConfigNode node, Dictionary<string, RadiationModel> models,
float x = Mathf.Cos(lat) * Mathf.Cos(lon);
float y = Mathf.Sin(lat);
float z = Mathf.Cos(lat) * Mathf.Sin(lon);
geomagnetic_pole = new Vector3(x, y, z);
geomagnetic_pole = new Vector3(x, y, z).normalized;
}

public string name; // name of the body
Expand All @@ -201,6 +202,7 @@ public RadiationBody(ConfigNode node, Dictionary<string, RadiationModel> models,
public int reference; // index of the body that determine x-axis of the gsm-space
public float geomagnetic_pole_lat = 90.0f;
public float geomagnetic_pole_lon = 0.0f;
public float geomagnetic_offset = 0.0f;
public Vector3 geomagnetic_pole;

// shortcut to the radiation environment
Expand Down Expand Up @@ -414,6 +416,9 @@ public static Space Gsm_space(RadiationBody rb, bool tilted)
gsm.y_axis = new Vector3(0.0f, 1.0f, 0.0f);
gsm.z_axis = new Vector3(0.0f, 0.0f, 1.0f);
}

gsm.origin = gsm.origin + gsm.y_axis * (gsm.scale * rb.geomagnetic_offset);

return gsm;
}

Expand Down

0 comments on commit d6e92e7

Please sign in to comment.