Skip to content

Commit

Permalink
core/math/fixed: implement BrFixedLength{2,3,4}()
Browse files Browse the repository at this point in the history
  • Loading branch information
vs49688 committed May 25, 2024
1 parent 5e628d5 commit f5703af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/inc/math_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ br_fixed_ls BR_PUBLIC_ENTRY BrFixedSqr4(br_fixed_ls a, br_fixed_ls b, br_fixed_l

/* result = sqrt(a*a + b*b)
*/
br_fixed_ls BR_ASM_CALL BrFixedLength2(br_fixed_ls a, br_fixed_ls b);
br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength2(br_fixed_ls a, br_fixed_ls b);

/* result = sqrt(a*a + b*b + c*c)
*/
br_fixed_ls BR_ASM_CALL BrFixedLength3(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c);
br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength3(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c);

/* result = sqrt(a*a + b*b + c*c + d*d)
*/
br_fixed_ls BR_ASM_CALL BrFixedLength4(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c, br_fixed_ls d);
br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength4(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c, br_fixed_ls d);

/* result = 1/sqrt(a*a + b*b) (low precision)
*/
Expand Down
15 changes: 15 additions & 0 deletions core/math/fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ br_fixed_ls BR_PUBLIC_ENTRY BrFixedSqr4(br_fixed_ls a, br_fixed_ls b, br_fixed_l
return BrFixedSqr(a) + BrFixedSqr(b) + BrFixedSqr(c) + BrFixedSqr(d);
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength2(br_fixed_ls a, br_fixed_ls b)
{
return BrFixedSqrt(BrFixedSqr2(a, b));
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength3(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c)
{
return BrFixedSqrt(BrFixedSqr3(a, b, c));
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedLength4(br_fixed_ls a, br_fixed_ls b, br_fixed_ls c, br_fixed_ls d)
{
return BrFixedSqrt(BrFixedSqr4(a, b, c, d));
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedDiv(br_fixed_ls numerator, br_fixed_ls denominator)
{
if(denominator == 0)
Expand Down

0 comments on commit f5703af

Please sign in to comment.