本文整理汇总了C#中Orbit.getRelativePositionFromTrueAnomaly方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.getRelativePositionFromTrueAnomaly方法的具体用法?C# Orbit.getRelativePositionFromTrueAnomaly怎么用?C# Orbit.getRelativePositionFromTrueAnomaly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orbit
的用法示例。
在下文中一共展示了Orbit.getRelativePositionFromTrueAnomaly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReallyDrawOrbit
// Fallback method: The orbit should be valid, but it's not showing as
// active. I've encountered this when targeting a vessel or planet.
private static void ReallyDrawOrbit(Orbit o, CelestialBody referenceBody, Matrix4x4 screenTransform, int numSegments)
{
if (o.eccentricity >= 1.0) {
Debug.Log("JSIOrbitDisplay.ReallyDrawOrbit(): I can't draw an orbit with e >= 1.0");
return;
}
double dTheta = 2.0 * Math.PI / (double)numSegments;
double theta = 0.0;
double now = Planetarium.GetUniversalTime();
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: 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;
}
}
示例3: SolveClosestBSP
static double SolveClosestBSP(ref double Fp, ref double Fs, double Ir, double dF, Orbit p, Orbit s, double epsilon, int maxIterations, ref int iterationCount)
{
double num = dF;
double num2 = dF;
if (Math.Abs(Ir) % 3.1415926535897931 * 2.0 > 1.5707963267948966)
{
num2 *= -1.0;
}
iterationCount = 0;
double num3 = (p.getRelativePositionFromTrueAnomaly(Fp) - s.getRelativePositionFromTrueAnomaly(Fs)).sqrMagnitude;
while (num > 0.0001)
{
if (iterationCount >= maxIterations)
{
return num3;
}
else
{
double sqrMagnitude = (p.getRelativePositionFromTrueAnomaly(Fp + num) - s.getRelativePositionFromTrueAnomaly(Fs + num2)).sqrMagnitude;
double sqrMagnitude2 = (p.getRelativePositionFromTrueAnomaly(Fp - num) - s.getRelativePositionFromTrueAnomaly(Fs - num2)).sqrMagnitude;
num3 = Math.Min(num3, Math.Min(sqrMagnitude, sqrMagnitude2));
if (num3 == sqrMagnitude)
{
Fp += num;
Fs += num2;
}
else if (num3 == sqrMagnitude2)
{
Fp -= num;
Fs -= num2;
}
num *= 0.5;
num2 *= 0.5;
iterationCount++;
}
}
return num3;
}