MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / xyToFacing

Function xyToFacing

game/state/city/vehicle.cpp:45–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43{
44static const float M_2xPI = 2.0f * M_PI;
45float xyToFacing(const Vec2<float> &xy)
46{
47 float a1 = acosf(-xy.y);
48 float a2 = asinf(xy.x);
49 return a2 >= 0 ? a1 : M_2xPI - a1;
50}
51Vec2<float> facingToXY(float facing) { return {sinf(facing), -cosf(facing)}; }
52// return the difference f1-f2 in the range [-pi;pi]
53// a negative return value means f1 is CCW from f2.

Callers 3

updateMethod · 0.85
updateMethod · 0.85
updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected