Browse Source

Use 'sq' macro where possible

pull/1/head
Scott Lahteine 8 years ago
parent
commit
b8ba3b7647
  1. 12
      Marlin/least_squares_fit.cpp
  2. 2
      Marlin/vector_3.cpp

12
Marlin/least_squares_fit.cpp

@ -66,12 +66,12 @@ int finish_incremental_LSF(struct linear_fit_data *lsf) {
lsf->xbar /= N; lsf->xbar /= N;
lsf->ybar /= N; lsf->ybar /= N;
lsf->zbar /= N; lsf->zbar /= N;
lsf->x2bar = lsf->x2bar / N - lsf->xbar * lsf->xbar; lsf->x2bar = lsf->x2bar / N - sq(lsf->xbar);
lsf->y2bar = lsf->y2bar / N - lsf->ybar * lsf->ybar; lsf->y2bar = lsf->y2bar / N - sq(lsf->ybar);
lsf->z2bar = lsf->z2bar / N - lsf->zbar * lsf->zbar; lsf->z2bar = lsf->z2bar / N - sq(lsf->zbar);
lsf->xybar = lsf->xybar / N - lsf->xbar * lsf->ybar; lsf->xybar = lsf->xybar / N - sq(lsf->xbar);
lsf->yzbar = lsf->yzbar / N - lsf->ybar * lsf->zbar; lsf->yzbar = lsf->yzbar / N - sq(lsf->ybar);
lsf->xzbar = lsf->xzbar / N - lsf->xbar * lsf->zbar; lsf->xzbar = lsf->xzbar / N - sq(lsf->xbar);
const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar); const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar);
if (fabs(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy)) if (fabs(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy))

2
Marlin/vector_3.cpp

@ -63,7 +63,7 @@ vector_3 vector_3::get_normal() {
return normalized; return normalized;
} }
float vector_3::get_length() { return sqrt((x * x) + (y * y) + (z * z)); } float vector_3::get_length() { return sqrt(sq(x) + sq(y) + sq(z)); }
void vector_3::normalize() { void vector_3::normalize() {
const float inv_length = 1.0 / get_length(); const float inv_length = 1.0 / get_length();

Loading…
Cancel
Save