// Compute rising edge timings (0.0 - 1.0) as a function of alpha-beta // as per the magnitude invariant clarke transform // The magnitude of the alpha-beta vector may not be larger than sqrt(3)/2 // Returns true on success, and false if the input was out of range std::tuple<float, float, float, bool> SVM(float alpha, float beta) { float tA, tB, tC; int Sextant;
if (beta >= 0.0f) { if (alpha >= 0.0f) { //quadrant I if (one_by_sqrt3 * beta > alpha) Sextant = 2; //sextant v2-v3 else Sextant = 1; //sextant v1-v2 } else { //quadrant II if (-one_by_sqrt3 * beta > alpha) Sextant = 3; //sextant v3-v4 else Sextant = 2; //sextant v2-v3 } } else { if (alpha >= 0.0f) { //quadrant IV if (-one_by_sqrt3 * beta > alpha) Sextant = 5; //sextant v5-v6 else Sextant = 6; //sextant v6-v1 } else { //quadrant III if (one_by_sqrt3 * beta > alpha) Sextant = 4; //sextant v4-v5 else Sextant = 5; //sextant v5-v6 } }