本文整理汇总了C#中Orbit.TrueAnomalyAtUT方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.TrueAnomalyAtUT方法的具体用法?C# Orbit.TrueAnomalyAtUT怎么用?C# Orbit.TrueAnomalyAtUT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orbit
的用法示例。
在下文中一共展示了Orbit.TrueAnomalyAtUT方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawOrbit
private static void DrawOrbit(Orbit o, CelestialBody referenceBody, Matrix4x4 screenTransform, int numSegments)
{
if (!o.activePatch) {
return;
}
double startTA;
double endTA;
double now = Planetarium.GetUniversalTime();
if (o.patchEndTransition != Orbit.PatchTransitionType.FINAL) {
startTA = o.TrueAnomalyAtUT(o.StartUT);
endTA = o.TrueAnomalyAtUT(o.EndUT);
if (endTA < startTA) {
endTA += 2.0 * Math.PI;
}
} else {
startTA = o.GetUTforTrueAnomaly(0.0, now);
endTA = startTA + 2.0 * Math.PI;
}
double dTheta = (endTA - startTA) / (double)numSegments;
double theta = startTA;
double timeAtTA = o.GetUTforTrueAnomaly(theta, now);
Vector3 lastVertex = screenTransform.MultiplyPoint3x4(o.getRelativePositionFromTrueAnomaly(theta).xzy + (o.referenceBody.getTruePositionAtUT(timeAtTA)) - (referenceBody.getTruePositionAtUT(timeAtTA)));
for (int i = 0; i < numSegments; ++i) {
GL.Vertex3(lastVertex.x, lastVertex.y, 0.0f);
theta += dTheta;
timeAtTA = o.GetUTforTrueAnomaly(theta, now);
Vector3 newVertex = screenTransform.MultiplyPoint3x4(o.getRelativePositionFromTrueAnomaly(theta).xzy + (o.referenceBody.getTruePositionAtUT(timeAtTA)) - (referenceBody.getTruePositionAtUT(timeAtTA)));
GL.Vertex3(newVertex.x, newVertex.y, 0.0f);
lastVertex = newVertex;
}
}
示例2: initMeshFromOrbit
private void initMeshFromOrbit(Vector3 bodyPosition, Mesh mesh, Orbit orbit, double startTime, double duration, Color color)
{
int steps = 128;
Vector3 camPos = ScaledSpace.ScaledToLocalSpace(MapView.MapCamera.transform.position) - bodyPosition;
double prevTA = orbit.TrueAnomalyAtUT(startTime);
double prevTime = startTime;
double[] stepUT = new double[steps * 4];
int utIdx = 0;
double maxDT = Math.Max(1.0, duration / (double)steps);
double maxDTA = 2.0 * Math.PI / (double)steps;
stepUT[utIdx++] = startTime;
while(true)
{
double time = prevTime + maxDT;
for (int count = 0; count < 100; ++count)
{
if (count == 99)
Debug.Log("WARNING: infinite loop? (Trajectories.MapOverlay.initMeshFromOrbit)");
double ta = orbit.TrueAnomalyAtUT(time);
while (ta < prevTA)
ta += 2.0 * Math.PI;
if (ta - prevTA <= maxDTA)
{
prevTA = ta;
break;
}
time = (prevTime + time) * 0.5;
}
if (time > startTime + duration - (time-prevTime) * 0.5)
break;
prevTime = time;
stepUT[utIdx++] = time;
if (utIdx >= stepUT.Length - 1)
{
//Util.PostSingleScreenMessage("ut overflow", "ut overflow");
break; // this should never happen, but better stop than overflow if it does
}
}
stepUT[utIdx++] = startTime + duration;
var vertices = new Vector3[utIdx * 2 + 2];
var triangles = new int[utIdx * 6];
Vector3 prevMeshPos = Util.SwapYZ(orbit.getRelativePositionAtUT(startTime - duration / (double)steps));
for(int i = 0; i < utIdx; ++i)
{
double time = stepUT[i];
Vector3 curMeshPos = Util.SwapYZ(orbit.getRelativePositionAtUT(time));
if (Settings.fetch.BodyFixedMode) {
curMeshPos = Trajectory.calculateRotatedPosition(orbit.referenceBody, curMeshPos, time);
}
// compute an "up" vector that is orthogonal to the trajectory orientation and to the camera vector (used to correctly orient quads to always face the camera)
Vector3 up = Vector3.Cross(curMeshPos - prevMeshPos, camPos - curMeshPos).normalized * (lineWidth * Vector3.Distance(camPos, curMeshPos));
// add a segment to the trajectory mesh
vertices[i * 2 + 0] = curMeshPos - up;
vertices[i * 2 + 1] = curMeshPos + up;
if (i > 0)
{
int idx = (i - 1) * 6;
triangles[idx + 0] = (i - 1) * 2 + 0;
triangles[idx + 1] = (i - 1) * 2 + 1;
triangles[idx + 2] = i * 2 + 1;
triangles[idx + 3] = (i - 1) * 2 + 0;
triangles[idx + 4] = i * 2 + 1;
triangles[idx + 5] = i * 2 + 0;
}
prevMeshPos = curMeshPos;
}
var colors = new Color[vertices.Length];
for (int i = 0; i < colors.Length; ++i)
{
//if (color.g < 0.5)
colors[i] = color;
/*else
colors[i] = new Color(0, (float)i / (float)colors.Length, 1.0f - (float)i / (float)colors.Length);*/
}
for (int i = 0; i < vertices.Length; ++i)
{
vertices[i] = ScaledSpace.LocalToScaledSpace(vertices[i] + bodyPosition);
}
mesh.Clear();
mesh.vertices = vertices;
mesh.colors = colors;
mesh.triangles = triangles;
mesh.RecalculateBounds();
//.........这里部分代码省略.........
示例3: initMeshFromOrbit
private void initMeshFromOrbit(Vector3 bodyPosition, Mesh mesh, Orbit orbit, double startTime, double duration, Color color)
{
int steps = 128;
double prevTA = orbit.TrueAnomalyAtUT(startTime);
double prevTime = startTime;
double[] stepUT = new double[steps * 4];
int utIdx = 0;
double maxDT = Math.Max(1.0, duration / (double)steps);
double maxDTA = 2.0 * Math.PI / (double)steps;
stepUT[utIdx++] = startTime;
while(true)
{
double time = prevTime + maxDT;
for (int count = 0; count < 100; ++count)
{
if (count == 99)
Debug.Log("WARNING: infinite loop? (Trajectories.MapOverlay.initMeshFromOrbit)");
double ta = orbit.TrueAnomalyAtUT(time);
while (ta < prevTA)
ta += 2.0 * Math.PI;
if (ta - prevTA <= maxDTA)
{
prevTA = ta;
break;
}
time = (prevTime + time) * 0.5;
}
if (time > startTime + duration - (time-prevTime) * 0.5)
break;
prevTime = time;
stepUT[utIdx++] = time;
if (utIdx >= stepUT.Length - 1)
{
//Util.PostSingleScreenMessage("ut overflow", "ut overflow");
break; // this should never happen, but better stop than overflow if it does
}
}
stepUT[utIdx++] = startTime + duration;
var vertices = new Vector3[utIdx * 2 + 2];
var uvs = new Vector2[utIdx * 2 + 2];
var triangles = new int[utIdx * 6];
Vector3 prevMeshPos = Util.SwapYZ(orbit.getRelativePositionAtUT(startTime - duration / (double)steps)) + bodyPosition;
for(int i = 0; i < utIdx; ++i)
{
double time = stepUT[i];
Vector3 curMeshPos = Util.SwapYZ(orbit.getRelativePositionAtUT(time));
if (Settings.fetch.BodyFixedMode) {
curMeshPos = Trajectory.calculateRotatedPosition(orbit.referenceBody, curMeshPos, time);
}
curMeshPos += bodyPosition;
// add a segment to the trajectory mesh
MakeRibbonEdge(prevMeshPos, curMeshPos, lineWidth, vertices, i * 2);
uvs[i * 2 + 0] = new Vector2(0.8f, 0);
uvs[i * 2 + 1] = new Vector2(0.8f, 1);
if (i > 0)
{
int idx = (i - 1) * 6;
triangles[idx + 0] = (i - 1) * 2 + 0;
triangles[idx + 1] = (i - 1) * 2 + 1;
triangles[idx + 2] = i * 2 + 1;
triangles[idx + 3] = (i - 1) * 2 + 0;
triangles[idx + 4] = i * 2 + 1;
triangles[idx + 5] = i * 2 + 0;
}
prevMeshPos = curMeshPos;
}
var colors = new Color[vertices.Length];
for (int i = 0; i < colors.Length; ++i)
{
//if (color.g < 0.5)
colors[i] = color;
/*else
colors[i] = new Color(0, (float)i / (float)colors.Length, 1.0f - (float)i / (float)colors.Length);*/
}
mesh.Clear();
mesh.vertices = vertices;
mesh.uv = uvs;
mesh.colors = colors;
mesh.triangles = triangles;
mesh.RecalculateBounds();
mesh.MarkDynamic();
}
示例4: AddOrbit
// UNITY
public static void AddOrbit(Kerbulator kalc, Orbit orbit, string prefix)
{
if(orbit == null)
return;
kalc.AddGlobal(new Variable(prefix +".Ap", VarType.NUMBER, (double)orbit.ApA));
kalc.AddGlobal(new Variable(prefix +".Pe", VarType.NUMBER, (double)orbit.PeA));
kalc.AddGlobal(new Variable(prefix +".Inc", VarType.NUMBER, (double)orbit.inclination));
kalc.AddGlobal(new Variable(prefix +".Alt", VarType.NUMBER, (double)orbit.altitude));
kalc.AddGlobal(new Variable(prefix +".ArgPe", VarType.NUMBER, (double)orbit.argumentOfPeriapsis));
kalc.AddGlobal(new Variable(prefix +".ω", VarType.NUMBER, (double)orbit.argumentOfPeriapsis));
kalc.AddGlobal(new Variable(prefix +".LAN", VarType.NUMBER, (double)orbit.LAN));
kalc.AddGlobal(new Variable(prefix +".Ω", VarType.NUMBER, (double)orbit.LAN));
kalc.AddGlobal(new Variable(prefix +".TimeToAp", VarType.NUMBER, (double)orbit.timeToAp));
kalc.AddGlobal(new Variable(prefix +".TimeToPe", VarType.NUMBER, (double)orbit.timeToPe));
kalc.AddGlobal(new Variable(prefix +".Vel", VarType.NUMBER, (double)orbit.vel.magnitude));
kalc.AddGlobal(new Variable(prefix +".TrueAnomaly", VarType.NUMBER, (double)orbit.trueAnomaly));
kalc.AddGlobal(new Variable(prefix +".θ", VarType.NUMBER, (double)orbit.trueAnomaly));
if(orbit.UTsoi > 0) {
kalc.AddGlobal(new Variable(prefix +".SOI.dt", VarType.NUMBER, (double)orbit.UTsoi-Planetarium.GetUniversalTime()));
kalc.AddGlobal(new Variable(prefix +".SOI.Δt", VarType.NUMBER, (double)orbit.UTsoi-Planetarium.GetUniversalTime()));
kalc.AddGlobal(new Variable(prefix +".SOI.TrueAnomaly", VarType.NUMBER, (double)orbit.TrueAnomalyAtUT(orbit.UTsoi)));
kalc.AddGlobal(new Variable(prefix +".SOI.θ", VarType.NUMBER, (double)orbit.TrueAnomalyAtUT(orbit.UTsoi)));
}
}