> For the complete documentation index, see [llms.txt](https://orbitronomy.gitbook.io/orbitronomy-official-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://orbitronomy.gitbook.io/orbitronomy-official-documentation/relativeorbit-class.md).

# RelativeOrbit Class

### Class Initialization

```python
class RelativeOrbit:
    def __init__(self, plot_title, name, fps=30):
```

* `plot_title` (str): The title of the orbital plot.
* `name` (str): The name of the celestial object you want to plot.
* `fps` (int): Frames per second for the animation (default is 30).

This class is initialized with a plot title, object name, and an optional frames per second value for the animation.

### Plot Styling

#### Setting Background Color

```python
def faceColor(self, face_color):
```

* `face_color` (str): Background color of the 3D plot.

Set the background color of the plot using this method. You can specify the color as a name (e.g., "white") or a hexadecimal code (e.g., "#F3EEEA").

#### Setting Axes Plane Color

```python
def paneColor(self, pane_color):
```

* `pane_color` (str): Color of the axes planes.

Change the color of the planes representing the X, Y, and Z axes using this method.

#### Setting Grid Color

```python
def gridColor(self, grid_color):
```

* `grid_color` (str): Color of grid lines.

Customize the color of the grid lines in the 3D plot to provide reference points.

#### Setting Label Color

```python
def labelColor(self, label_color):
```

* `label_color` (str): Color of axis labels.

Customize the color of the X, Y, and Z axis labels for better visibility or style matching.

#### Setting Tick Color

```python
def tickColor(self, tick_color):
```

* `tick_color` (str): Color of axis ticks.

Specify the color of the ticks on the X, Y, and Z axes to align them with the plot's style.

#### Setting Orbit Transparency

```python
def orbitTransparencyParentObject(self, orbit_transparency_parent_object):
def orbitTransparencyChildObject(self, orbit_transparency_child_object):
```

* `orbit_transparency_parent_object`, `orbit_transparency_child_object` (float): Transparency of orbit lines (0.0 to 1.0) for the parent and child objects.

Control the transparency of the plotted orbit lines for the parent and child objects separately. A value of 0.0 means fully transparent, while 1.0 means fully opaque.

#### Setting Object Colors

```python
def colorParentObjectOrbit(self, color_parent_object_orbit):
def colorChildObjectOrbit(self, color_child_object_orbit):
```

* `color_parent_object_orbit`, `color_child_object_orbit` (list): Colors for the parent and child object and their orbits (e.g., \["blue", "green"]).

Specify the colors for the parent and child objects as well as their respective orbit lines.

#### Setting Object Sizes

```python
def sunSize(self, sun_size):
def parentObjectSize(self, parent_object_size):
def childObjectSize(self, child_object_size):
```

* `sun_size`, `parent_object_size`, `child_object_size` (int): Sizes of the Sun, parent object, and child object in the plot.

Customize the size of the Sun, parent object, and child object in the plot using these methods.

### Data Input and Plot Generation

#### Generating Orbital Plot

```python
def calculateOrbit(self, plot_steps, n_orbits_child=1, data=None, 
                   color=None, trajectory=False, sun=True, 
                   child_trajectory=True, n_orbits_parent=1):
```

* `plot_steps` (int): Number of steps for plotting the orbit.
* `n_orbits_child` (int): Number of orbital periods to plot for the child object (default is 1).
* `data` (list of lists): List of celestial objects' data. Each sublist should contain the name, semi-major axis, perihelion, eccentricity, inclination, longitude of ascending node, argument of perihelion, and color (optional).
* `color` (str): Default color for celestial objects (optional).
* `trajectory` (bool): Whether to plot the object's trajectory (default is False).
* `sun` (bool): Whether to plot the Sun at the center (default is True).
* `child_trajectory` (bool): Whether to plot the child object's trajectory (default is True).
* `n_orbits_parent` (int): Number of orbital periods to plot for the parent object (default is 1).

Use this method to generate 3D orbital plots for parent-child celestial object systems. You can either provide a list of celestial object data or specify the orbital parameters individually for a single object.

#### Animating the Orbit

```python
def animateOrbit(self, dpi, save=False, export_zoom=None, font_size="xx-small", export_folder=None, animation_interval=40, x_lim=None, y_lim=None, z_lim=None, x_label="X-Axis", y_label="Y-Axis", z_label="Z-Axis"):
```

* `dpi` (int): Dots per inch for the animation.
* `save` (bool): Whether to save the animation as a GIF (default is False).
* `export_zoom` (int): Zoom level for the exported GIF (optional).
* `font_size` (str): Font size for the legend (optional).
* `export_folder` (str): Folder to save the GIF (optional).
* `animation_interval` (int): Interval between animation frames (default is 40).
* `x_lim`, `y_lim`, `z_lim` (list): Lists containing the X, Y, and Z axis limits (optional).
* `x_label`, `y_label`, `z_label` (str): Labels for the X, Y, and Z axes (optional).

This method animates the generated orbital plot. You can specify various parameters like export settings, axis labels, and animation interval.

#### Setting Axis Limits

```python
def xLim(self, x_lim):
def yLim(self, y_lim):
def zLim(self, z_lim):
```

* `x_lim`, `y_lim`, `z_lim` (list): Lists containing axis limits.

You can use these methods to set custom limits for the X, Y, and Z axes to focus on specific regions of the plot.

#### Setting Axis Labels

```python
def xLabel(self, x_label):
def yLabel(self, y_label):
def zLabel(self, z_label):
```

* `x_label`, `y_label`, `z_label` (str): Labels for the X, Y, and Z axes.

Use these methods to label the axes in the plot with the desired text.

### Example Usage

```python
# Import the RelativeOrbit class and other required libraries
from orbitronomy import RelativeOrbit

# Create a RelativeOrbit object with a plot title and object name
test = RelativeOrbit(plot_title="Test", name="Earth", fps=30)

# Styling the plot
test.faceColor("black")
test.paneColor("black")
test.gridColor("#222831")
test.labelColor("white")
test.tickColor("white")
test.orbitTransparencyParentObject(0.5)
test.orbitTransparencyChildObject(0.5)
test.colorParentObjectOrbit(["blue", "green"])
test.colorChildObjectOrbit(["red", "white"])

# Setting Keplerian elements for the parent and child objects
test.semiMajorAxisParentObject(1)
test.perihelionParentObject(0.983289891)
test.eccentricityParentObject(0.01671123)
test.inclinationParentObject(0)
test.longitudeOfAscendingNodeParentObject(0)
test.argumentOfPerihelionParentObject(0)

test.semiMajorAxisChildObject(0.4)
test.perihelionChildObject(0.45)
test.eccentricityChildObject(0.1)
test.inclinationChildObject(10)
test.longitudeOfAscendingNodeChildObject(0)
test.argumentOfPerihelionChildObject(0)

# Customize object and orbit sizes
test.sunSize(100)
test.parentObjectSize(100)
test.childObjectSize(100)

# Generate and animate the orbital plot
test.calculateOrbit(plot_steps=1000, n_orbits_child=3, n_orbits_parent=1, trajectory=True, sun=True, child_trajectory=True)
test.xLim([20, 20])
test.yLim([20, 20])
test.zLim([1, 1])

test.xLabel("X-Axis")
test.yLabel("Y-Axis")
test.zLabel("Z-Axis")
test.animateOrbit(dpi=250, save=False, export_zoom=3, export_folder="results", font_size="xx-small", animation_interval=10)
```

This example demonstrates the usage of the `ParentChildOrbit` class to create a customized 3D orbital plot and animate it. It includes setting plot styles, specifying orbital parameters, and generating the animation.

Please note that this documentation provides an overview of the `ParentChildOrbit` class and its methods. Additional details can be found in the inline comments within the class implementation.
