Skip to content

Commit

Permalink
Revert "sqrt() is a lot cheaper than cos() or sin()"
Browse files Browse the repository at this point in the history
This reverts commit 361268b.

The CPU time saved does not justify the extra code complexity.
  • Loading branch information
tombrazier committed Jun 20, 2022
1 parent 816f916 commit 3c3c060
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Marlin/src/gcode/motion/G2_G3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,7 @@ void plan_arc(
// Compute exact location by applying transformation matrix from initial radius vector(=-offset).
// To reduce stuttering, the sin and cos could be computed at different times.
// For now, compute both at the same time.
const float angle = i * theta_per_segment,
cos_Ti = cos(angle),
abs_sin_Ti = SQRT(1 - cos_Ti * cos_Ti),
sin_Ti = angle > M_PI || (angle < 0.0f && angle > -M_PI) ? -abs_sin_Ti : abs_sin_Ti;
const float cos_Ti = cos(i * theta_per_segment), sin_Ti = sin(i * theta_per_segment);
rvec.a = -offset[0] * cos_Ti + offset[1] * sin_Ti;
rvec.b = -offset[0] * sin_Ti - offset[1] * cos_Ti;
}
Expand Down

0 comments on commit 3c3c060

Please sign in to comment.