I have two Spatials (viewerSource, geom) and I want to figure out whether the geom is relative to the viewerSource’s translation and rotation ± a specific angle.
It’s hard to describe without knowing the right words, here’s an image:
Where steer will be between -1 and 1 for steering right or left suitable for plugging directly into a steering behavior.
Caveats:
angleBetween() should give you -180 to 180 which is probably desirably for your narrow use-case.
the ‘steer’ approach gives -1 to 1 but that means -90 to 90… things behind you would still need to be detected… but usually for steering you also do an unnormalized dot with the forward vector.
float forward = forwardDir.dot(relativeOffset);
…which lets the steering behavior decide if it has arrived yet or if the target is behind them, whether they should turn or back up, etc…