## 3 Proposed Approach
### Forbidden Sector Detection
The algorithms presented here are based to a large extent on discussions available online [22]. Algorithm 5 constructs a tetrahedron with the apex oriented towards the destination node and with the sender node located at the center of the base. We use the convention that \(T\).v1, \(T\).v2 and \(T\).v3 are the coordinates for the three vertices defining the base of the tetrahedron \(T\). The position of the tetrahedron apex (forth vertex) is available in \(T\).v4. Figure 4: Forbidden sector detection. To the left: 3D view of detector operation. To the right: cross-section of 3D radiation pattern with detector. Ratio between size of main lobe and size of sidelobes is decreased on purpose in order for the sidelobes to be visible in the figure. ```
0: sender, receiver, set of adversary nodes
1:procedureIs_Forbidden_Sector(src,dst,\(\mathcal{A}\))
2:\(T\leftarrow\textsc{Tetrahedron}(src.pos,dst.pos)\)
3:for each node \(a\in\mathcal{A}\)do
4:ifIsInside(\(T\), \(a\)) = True then
5:return True
6:endif
7:endfor
8:return False
9:endprocedure
```  
**Algorithm 5** Forbidden sector detection. The attribute pos appearing to the right of a node variable (e.g., _src_ and _dst_) contains the 3D coordinates of that node. The algorithms iterates through all adversary nodes, calling the IsInside procedure (Algorithm 6) to check if any generate a forbidden sector. In that case, the algorithm aborts and returns True. Otherwise, if none of the adversaries are located within the tetrahedron space, the algorithm returns False. Algorithm 6 checks for each of the four planes making up the tetrahedron if the opposite vertex and the adversary node are located on the same side of the plane. If this is true for all planes, it means that the position of the adversary is a point located inside the tetrahedron. Otherwise, the adversary is on the outside. ```
0: tetrahedron, adversary node
1:procedureIs_Inside(\(T\), \(a\))
2:\(p1\leftarrow\textsc{Is}\_\textsc{On}\_\textsc{Same}\_\textsc{Plane}\_\textsc{Side}(T.v1,T.v2,T.v3,T.v4,\(a\).pos)\)
3:\(p2\leftarrow\textsc{Is}\_\textsc{On}\_\textsc{Same}\_\textsc{Plane}\_\textsc{Side}(T.v2,T.v3,T.v4,T.v1,\(a\).pos)\)
4:\(p3\leftarrow\textsc{Is}\_\textsc{On}\_\textsc{Same}\_\textsc{Plane}\_\textsc{Side}(T.v3,T.v4,T.v1,T.v2,\(a\).pos)\)
5:\(p4\leftarrow\textsc{Is}\_\textsc{On}\_\textsc{Same}\_\textsc{Plane}\_\textsc{Side}(T.v4,T.v1,T.v2,T.v3,\(a\).pos)\)
6:if\(p1\) = True and \(p2\) = True and \(p3\) = True and \(p4\) = True then
7:return True
8:else
9:return False
10:endif
11:endprocedure
```  
**Algorithm 6** Check if adversary is within tetrahedron. The logic to detect if the opposite vertex and the adversary are located on the same side of a plane is shown in Algorithm 7. The first three input parameters, \(\mathbf{p}\), \(\mathbf{q}\) and \(\mathbf{r}\), are the coordinates of the vertices defining the plane. Vertex \(\mathbf{p}\) is used as common origin when using the coordinates to construct two vectors, \(\mathbf{q}-\mathbf{p}\) and \(\mathbf{r}-\mathbf{p}\), that span the plane. The cross-product \(\mathbf{n}\) of these two vectors is perpendicular to the two vectors spanning the plane, and is thus a normal to the plane. Similarly, we use the remaining two parameters \(\mathbf{v}\) and \(\mathbf{a}\) to construct two vectors \(\mathbf{v}-\mathbf{p}\) and \(\mathbf{a}-\mathbf{p}\), using the same origin \(\mathbf{p}\) as before. The normal \(\mathbf{n}\) is then used as a reference direction when computing the dot products of the normal with these two vectors. The dot product returns a positive value if the angle \(\theta\) between the vector and normal is \(-\pi<\theta<\pi\) and it returns a negative value when \(\pi<\theta<3\pi\). When the vector and normal are perpendicular their dot product is zero. Therefore, if both dot products, \(d1\) and \(d2\), have the same sign, it means that \(\mathbf{v}\) and \(\mathbf{a}\) are on the same side of the plane. When both dot products are zero, it means that the two vectors are on the plane.