瀏覽代碼

Use 'sq' macro where possible

Scott Lahteine 7 年之前
父節點
當前提交
b8ba3b7647
共有 2 個文件被更改,包括 7 次插入7 次删除
  1. 6
    6
      Marlin/least_squares_fit.cpp
  2. 1
    1
      Marlin/vector_3.cpp

+ 6
- 6
Marlin/least_squares_fit.cpp 查看文件

@@ -66,12 +66,12 @@ int finish_incremental_LSF(struct linear_fit_data *lsf) {
66 66
   lsf->xbar /= N;
67 67
   lsf->ybar /= N;
68 68
   lsf->zbar /= N;
69
-  lsf->x2bar = lsf->x2bar / N - lsf->xbar * lsf->xbar;
70
-  lsf->y2bar = lsf->y2bar / N - lsf->ybar * lsf->ybar;
71
-  lsf->z2bar = lsf->z2bar / N - lsf->zbar * lsf->zbar;
72
-  lsf->xybar = lsf->xybar / N - lsf->xbar * lsf->ybar;
73
-  lsf->yzbar = lsf->yzbar / N - lsf->ybar * lsf->zbar;
74
-  lsf->xzbar = lsf->xzbar / N - lsf->xbar * lsf->zbar;
69
+  lsf->x2bar = lsf->x2bar / N - sq(lsf->xbar);
70
+  lsf->y2bar = lsf->y2bar / N - sq(lsf->ybar);
71
+  lsf->z2bar = lsf->z2bar / N - sq(lsf->zbar);
72
+  lsf->xybar = lsf->xybar / N - sq(lsf->xbar);
73
+  lsf->yzbar = lsf->yzbar / N - sq(lsf->ybar);
74
+  lsf->xzbar = lsf->xzbar / N - sq(lsf->xbar);
75 75
 
76 76
   const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar);
77 77
   if (fabs(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy))

+ 1
- 1
Marlin/vector_3.cpp 查看文件

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

Loading…
取消
儲存