# Nebula geometry format

The "geometry file" encodes the interfaces between volumes as triangles. It is a text file, where each line represents a triangle. There are 11 numbers per line. The first two are integers, representing the materials on either side; the others represent the coordinates of the triangle vertices in nanometers. The order is

```
(mat_in mat_out) (x1 y1 z1) (x2 y2 z2) (x2 y3 z3)
```

where parentheses were added for clarity. We are in a right-handed coordinate system.

The "normal" direction of the triangle is defined as

```
[(x2 y2 z2)-(x1 y1 z1)] × [(x3 y3 z3)-(x1 y1 z1)]
```

where × is the cross product. This normal points into the direction that is
represented by `mat_out`

.

Example:

```
0 -123 -100 -100 0 100 -100 0 100 100 0
0 -123 -100 -100 0 100 100 0 -100 100 0
```

These two triangles form a square plane between (x,y) = (-100, -100) and (x,y) = (100, 100), at z = 0. In this case, the outer products are (200, 0, 0) × (200, 200, 0) = (0, 0, 40000) and (200, 200, 0) × (0, 200, 0) = (0, 0, 40000). So both normals are in the positive z direction. Material -123 is on the +z side and material 0 is on the -z side.

Positive material indices correspond to the materials you provide on the command
line. You can use more than one material in the simulation, in which case you
would run, for example, `./nebula tri pri silicon silicondioxide pmma`

. In that
case, silicon would be material 0, silicondioxide would be material 1 and pmma
would be material 2. There are a few special materials, with negative indices:

- -122 Ideal mirror
- -123 Vacuum
- -124 BSE detector: detect the electron if it has 50eV or more, pass it through otherwise
- -125 SE detector: detect the electron if it has less than 50eV, pass it through otherwise
- -126 Detector: detect the electron
- -127 Terminator: kills every electron that tries to move into this material
- -128 Does nothing