Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

PatchedConicSolver: Difference between revisions

From Kerbal Space Program 2 Modding Wiki
Spacewarp>Schlosrat
Initial documentation of the PatchedConicSolver class
 
Spacewarp>Schlosrat
Added Called By/Used By details where available
Line 30: Line 30:


== PatchedConicSolver.OnStart() ==
== PatchedConicSolver.OnStart() ==
'''Called by:''' TBD
'''Called by:''' ''VesselComponent.OnStart(double)''


  The ''PatchedConicSolver.OnStart()'' method adds a new handler for the ''Orbiter.OnReferenceBodyChange'' method so that OnReferenceBodyChange will be called when necessary. It then sets the private _patchLimit to be the max of ''PersistentProfileManager.ConicPatchLimit'' and 1, adds this.Orbiter.PatchedConicsOrbit to the ''CurrentTrajectory'' list, and similarly adds any remaining patches from 1 to MaxTotalPatches.
  The ''PatchedConicSolver.OnStart()'' method adds a new handler for the ''Orbiter.OnReferenceBodyChange'' method so that OnReferenceBodyChange will be called when necessary. It then sets the private _patchLimit to be the max of ''PersistentProfileManager.ConicPatchLimit'' and 1, adds this.Orbiter.PatchedConicsOrbit to the ''CurrentTrajectory'' list, and similarly adds any remaining patches from 1 to MaxTotalPatches.


== PatchedConicSolver.OnUpdate() ==
== PatchedConicSolver.OnUpdate() ==
'''Called By:''' TBD
'''Called By:''' ''VesselComponent.OnUpdateOrbit()''


  The ''PatchedConicSolver.OnUpdate()'' method first calls ''PatchedConicSolver.SetPatchesInactive'', then calls private methods for ''InitializeFirstPatch()'' and ''CalculatePatchList()'' to ensure the patches are updated.
  The ''PatchedConicSolver.OnUpdate()'' method first calls ''PatchedConicSolver.SetPatchesInactive'', then calls private methods for ''InitializeFirstPatch()'' and ''CalculatePatchList()'' to ensure the patches are updated.
'''NOTE:''' When called by ''VesselComponent.OnUpdateOrbit()'', this method is called ''before'' calling ''orbiter.ManeuverPlanSolver.OnUpdate()''.


== PatchedConicSolver.SetPatchesInactive(List<PatchedConicsOrbit>, int) ==
== PatchedConicSolver.SetPatchesInactive(List<PatchedConicsOrbit>, int) ==
'''Called By:''' ''OnUpdate''
'''Called By:''' ''OnUpdate'', ''ManeuverPlanSolver.UpdateManeuverTrajectory()''


  The ''PatchedConicSolver.SetPatchesInactive()'' method accepts a list of patches (i.e., ''CurrentTrajectory'') and (optionally) a starting index for the list (defaults to 0). For each list member from the starting index to the end of the list, the member's ActivePatch property is set to ''false''.
  The ''PatchedConicSolver.SetPatchesInactive()'' method accepts a list of patches (i.e., ''CurrentTrajectory'') and (optionally) a starting index for the list (defaults to 0). For each list member from the starting index to the end of the list, the member's ActivePatch property is set to ''false''.
'''NOTE:''' When called by ''ManeuverPlanSolver.UpdateManeuverTrajectory()'', this method is called ''after'' calling ''ManeuverPlanSolver.SetPatchesInactive''


== PatchedConicSolver.SetTarget(CelestialBodyComponent) ==
== PatchedConicSolver.SetTarget(CelestialBodyComponent) ==
'''Called By:''' TBD
'''Called By:''' ''VesselComponent.TargetObject''


  The ''PatchedConicSolver.SetTarget()'' method accepts a CelestialBodyComponent and uses that to set the private _targetBody property.
  The ''PatchedConicSolver.SetTarget()'' method accepts a CelestialBodyComponent and uses that to set the private _targetBody property.


== PatchedConicsOrbit.FindPatchContainingUT(double) ==
== PatchedConicsOrbit.FindPatchContainingUT(double) ==
'''Called By:''' TBD
'''Called By:''' ''OrbitalReadoutInstrumentManager.Update()'', ''ManeuverPlanComponent.IsValidNode()'', ''ManeuverPlanComponent.UpdateNodeDetails()'', ''ManeuverPlanComponent.GetManeuverNodeBurnDirVector()'', and ''ManeuverPlanComponent.SolveManeuver()''


  The ''PatchedConicsOrbit FindPatchContainingUT()'' method accepts a double (the universal time of interest) and returns the ''PatchedConicOrbit'' for the patch associated with that time.
  The ''PatchedConicsOrbit FindPatchContainingUT()'' method accepts a double (the universal time of interest) and returns the ''PatchedConicOrbit'' for the patch associated with that time.
Line 65: Line 67:


== PatchedConicsOrbit.RefreshPatchLimit() ==
== PatchedConicsOrbit.RefreshPatchLimit() ==
'''Called By:''' TBD
'''Called By:''' ''GameplaySettingsMenuManager.ApplyConicPatchLimit()''


  The ''PatchedConicsOrbit.RefreshPatchLimit()'' method clamps the current setting of the private _pathcLimit property to be between 1 and 5 inclusively.
  The ''PatchedConicsOrbit.RefreshPatchLimit()'' method clamps the current setting of the private _pathcLimit property to be between 1 and 5 inclusively.


== PatchedConicsOrbit.SolverParameters ==
== PatchedConicsOrbit.SolverParameters ==
'''Called By:''' TBD
'''Called By:''' ''PatchedConics.GetClosestApproach()'', ''PatchedConics.EncountersBody()'', ''PatchedConics.CheckEncounter()''
 
'''Used By:''' ''ManeuverPlanSolver'', ''PatchedConicSolver''


  The ''PatchedConicsOrbit.SolverParameters'' class defines the parameters needed for the solver with default values assigned to ''maxGeometrySolverIterations'' (25), ''maxTimeSolverIterations'' (50), and ''outerReaches'' (1E+20).
  The ''PatchedConicsOrbit.SolverParameters'' class defines the parameters needed for the solver with default values assigned to ''maxGeometrySolverIterations'' (25), ''maxTimeSolverIterations'' (50), and ''outerReaches'' (1E+20).

Revision as of 18:10, 26 May 2023

PatchedConicSolver is a class that is part of Orbiter objects. It is used to capture, generate, update, and provide access to patched conics information relating to the Orbiter object it is associated with. The PatchedConicSolver class has the following public members.

Namespace: KSP.Sim.impl

PatchedConicSolver.MaxTotalPatches

Type: int

The maximum limit on the number of patches. The default value = 10. This member can be get, but not set.

PatchedConicSolver.Orbiter

Type: OrbiterComponent

The ObiterComponent object this class is associated with. This member can be get, but not set.

PatchedConicSolver.CurrentTrajectory[index]

Type: List<PatchedConicsOrbit>

A list of PatchedConicOrbits. May be given an index to obtain a particular trajectory. It’s basically a list of all the trajectories currently associated with this Orbiter object, and you can do things with it like any list. The length of the list will be no longer than MaxTotalPatches, with list members being chronologically organized from the patch that occurs first to the last patch. Unused members are null. This member can be get, but not set.

PatchedConicSolver.PatchesAhead

Type: int

The number of patches ahead. This member can be get or set. It is set in the private method PatchedConicSolver.CalculatePatchList()

PatchedConicSolver.OnDestroy()

Called by: TBD

The PatchedConicSolver.OnDestroy() method first tests to see if the Orbiter object is null. If it is, then it returns immediately. Otherwise, it will remove the handler for OnReferenceBodyChange which was added by the OnStart method.

PatchedConicSolver.OnStart()

Called by: VesselComponent.OnStart(double)

The PatchedConicSolver.OnStart() method adds a new handler for the Orbiter.OnReferenceBodyChange method so that OnReferenceBodyChange will be called when necessary. It then sets the private _patchLimit to be the max of PersistentProfileManager.ConicPatchLimit and 1, adds this.Orbiter.PatchedConicsOrbit to the CurrentTrajectory list, and similarly adds any remaining patches from 1 to MaxTotalPatches.

PatchedConicSolver.OnUpdate()

Called By: VesselComponent.OnUpdateOrbit()

The PatchedConicSolver.OnUpdate() method first calls PatchedConicSolver.SetPatchesInactive, then calls private methods for InitializeFirstPatch() and CalculatePatchList() to ensure the patches are updated.
NOTE: When called by VesselComponent.OnUpdateOrbit(), this method is called before calling orbiter.ManeuverPlanSolver.OnUpdate().

PatchedConicSolver.SetPatchesInactive(List<PatchedConicsOrbit>, int)

Called By: OnUpdate, ManeuverPlanSolver.UpdateManeuverTrajectory()

The PatchedConicSolver.SetPatchesInactive() method accepts a list of patches (i.e., CurrentTrajectory) and (optionally) a starting index for the list (defaults to 0). For each list member from the starting index to the end of the list, the member's ActivePatch property is set to false.
NOTE: When called by ManeuverPlanSolver.UpdateManeuverTrajectory(), this method is called after calling ManeuverPlanSolver.SetPatchesInactive

PatchedConicSolver.SetTarget(CelestialBodyComponent)

Called By: VesselComponent.TargetObject

The PatchedConicSolver.SetTarget() method accepts a CelestialBodyComponent and uses that to set the private _targetBody property.

PatchedConicsOrbit.FindPatchContainingUT(double)

Called By: OrbitalReadoutInstrumentManager.Update(), ManeuverPlanComponent.IsValidNode(), ManeuverPlanComponent.UpdateNodeDetails(), ManeuverPlanComponent.GetManeuverNodeBurnDirVector(), and ManeuverPlanComponent.SolveManeuver()

The PatchedConicsOrbit FindPatchContainingUT() method accepts a double (the universal time of interest) and returns the PatchedConicOrbit for the patch associated with that time.

PatchedConicsOrbit.DecreasePatchLimit()

Called By: TBD

The PatchedConicsOrbit.DecreasePatchLimit() method decreased the current setting of the private _pathcLimit property by 1 to a value that is never less than 1.

PatchedConicsOrbit.IncreasePatchLimit()

Called By: TBD

The PatchedConicsOrbit.IncreasePatchLimit() method increases the current setting of the private _pathcLimit property by 1 to a value that is never more than 5.

PatchedConicsOrbit.RefreshPatchLimit()

Called By: GameplaySettingsMenuManager.ApplyConicPatchLimit()

The PatchedConicsOrbit.RefreshPatchLimit() method clamps the current setting of the private _pathcLimit property to be between 1 and 5 inclusively.

PatchedConicsOrbit.SolverParameters

Called By: PatchedConics.GetClosestApproach(), PatchedConics.EncountersBody(), PatchedConics.CheckEncounter()

Used By: ManeuverPlanSolver, PatchedConicSolver

The PatchedConicsOrbit.SolverParameters class defines the parameters needed for the solver with default values assigned to maxGeometrySolverIterations (25), maxTimeSolverIterations (50), and outerReaches (1E+20).