-
Notifications
You must be signed in to change notification settings - Fork 1.7k
add arc functions to ipf #11179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: maintenance-10.x
Are you sure you want to change the base?
add arc functions to ipf #11179
Conversation
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
…pr-branch-suggestion Add GitHub Action to suggest version branches for PRs
Branch Targeting SuggestionYou've targeted the
If This is an automated suggestion to help route contributions to the appropriate branch. |
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
| case LOGIC_CONDITION_ASIN: | ||
| temporaryValue = (operandB == 0) ? 1000 : operandB; | ||
| return RADIANS_TO_DEGREES(asin_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Correct the LOGIC_CONDITION_ASIN implementation, which currently computes ACOS instead of ASIN, by applying the acos_to_asin_approx macro to the result. [possible issue, importance: 9]
| case LOGIC_CONDITION_ASIN: | |
| temporaryValue = (operandB == 0) ? 1000 : operandB; | |
| return RADIANS_TO_DEGREES(asin_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); | |
| break; | |
| case LOGIC_CONDITION_ASIN: | |
| temporaryValue = (operandB == 0) ? 1000 : operandB; | |
| return RADIANS_TO_DEGREES(acos_to_asin_approx(acos_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f)))); | |
| break; |
| case LOGIC_CONDITION_ATAN2: | ||
| return RADIANS_TO_DEGREES(atan2_approx((float)operandA, (float)operandB)); | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Normalize the returned degrees to a defined range (e.g., (-180, 180]) and add an explicit fallback for the (0,0) input so consumers don't depend on undefined/implementation-specific angle conventions. [Learned best practice, importance: 6]
| case LOGIC_CONDITION_ATAN2: | |
| return RADIANS_TO_DEGREES(atan2_approx((float)operandA, (float)operandB)); | |
| break; | |
| case LOGIC_CONDITION_ATAN2: { | |
| if (operandA == 0 && operandB == 0) { | |
| return 0; | |
| } | |
| float deg = RADIANS_TO_DEGREES(atan2_approx((float)operandA, (float)operandB)); | |
| while (deg <= -180.0f) deg += 360.0f; | |
| while (deg > 180.0f) deg -= 360.0f; | |
| return (int32_t)deg; | |
| } break; |
| case LOGIC_CONDITION_ACOS: | ||
| temporaryValue = (operandB == 0) ? 1000 : operandB; | ||
| return RADIANS_TO_DEGREES(acos_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); | ||
| break; | ||
|
|
||
| case LOGIC_CONDITION_ASIN: | ||
| temporaryValue = (operandB == 0) ? 1000 : operandB; | ||
| return RADIANS_TO_DEGREES(asin_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Use a float denominator (with a safe default) and compute the clamped ratio once to avoid repeated casts and make the boundary behavior explicit and consistent. [Learned best practice, importance: 5]
| case LOGIC_CONDITION_ACOS: | |
| temporaryValue = (operandB == 0) ? 1000 : operandB; | |
| return RADIANS_TO_DEGREES(acos_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); | |
| break; | |
| case LOGIC_CONDITION_ASIN: | |
| temporaryValue = (operandB == 0) ? 1000 : operandB; | |
| return RADIANS_TO_DEGREES(asin_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); | |
| break; | |
| case LOGIC_CONDITION_ACOS: { | |
| const float denom = (operandB == 0) ? 1000.0f : (float)operandB; | |
| const float ratio = constrainf((float)operandA / denom, -1.0f, 1.0f); | |
| return RADIANS_TO_DEGREES(acos_approx(ratio)); | |
| } break; | |
| case LOGIC_CONDITION_ASIN: { | |
| const float denom = (operandB == 0) ? 1000.0f : (float)operandB; | |
| const float ratio = constrainf((float)operandA / denom, -1.0f, 1.0f); | |
| return RADIANS_TO_DEGREES(asin_approx(ratio)); | |
| } break; |
User description
Added asin/acos/atan2 functions to IPF