Browse Source

Tweaks to cubic_b_spline code style

Scott Lahteine 7 years ago
parent
commit
dac1f6fe74
1 changed files with 16 additions and 16 deletions
  1. 16
    16
      Marlin/src/module/planner_bezier.cpp

+ 16
- 16
Marlin/src/module/planner_bezier.cpp View File

@@ -111,10 +111,10 @@ inline static float dist1(float x1, float y1, float x2, float y2) { return FABS(
111 111
  */
112 112
 void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS], const float offset[4], float fr_mm_s, uint8_t extruder) {
113 113
   // Absolute first and second control points are recovered.
114
-  float first0 = position[X_AXIS] + offset[0];
115
-  float first1 = position[Y_AXIS] + offset[1];
116
-  float second0 = target[X_AXIS] + offset[2];
117
-  float second1 = target[Y_AXIS] + offset[3];
114
+  const float first0 = position[X_AXIS] + offset[0],
115
+              first1 = position[Y_AXIS] + offset[1],
116
+              second0 = target[X_AXIS] + offset[2],
117
+              second1 = target[Y_AXIS] + offset[3];
118 118
   float t = 0.0;
119 119
 
120 120
   float bez_target[4];
@@ -138,15 +138,15 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
138 138
     bool did_reduce = false;
139 139
     float new_t = t + step;
140 140
     NOMORE(new_t, 1.0);
141
-    float new_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], new_t);
142
-    float new_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], new_t);
141
+    float new_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], new_t),
142
+          new_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], new_t);
143 143
     for (;;) {
144 144
       if (new_t - t < (MIN_STEP)) break;
145
-      float candidate_t = 0.5 * (t + new_t);
146
-      float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
147
-      float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
148
-      float interp_pos0 = 0.5 * (bez_target[X_AXIS] + new_pos0);
149
-      float interp_pos1 = 0.5 * (bez_target[Y_AXIS] + new_pos1);
145
+      const float candidate_t = 0.5 * (t + new_t),
146
+                  candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t),
147
+                  candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t),
148
+                  interp_pos0 = 0.5 * (bez_target[X_AXIS] + new_pos0),
149
+                  interp_pos1 = 0.5 * (bez_target[Y_AXIS] + new_pos1);
150 150
       if (dist1(candidate_pos0, candidate_pos1, interp_pos0, interp_pos1) <= (SIGMA)) break;
151 151
       new_t = candidate_t;
152 152
       new_pos0 = candidate_pos0;
@@ -157,12 +157,12 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
157 157
     // If we did not reduce the step, maybe we should enlarge it.
158 158
     if (!did_reduce) for (;;) {
159 159
       if (new_t - t > MAX_STEP) break;
160
-      float candidate_t = t + 2.0 * (new_t - t);
160
+      const float candidate_t = t + 2.0 * (new_t - t);
161 161
       if (candidate_t >= 1.0) break;
162
-      float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
163
-      float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
164
-      float interp_pos0 = 0.5 * (bez_target[X_AXIS] + candidate_pos0);
165
-      float interp_pos1 = 0.5 * (bez_target[Y_AXIS] + candidate_pos1);
162
+      const float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t),
163
+                  candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t),
164
+                  interp_pos0 = 0.5 * (bez_target[X_AXIS] + candidate_pos0),
165
+                  interp_pos1 = 0.5 * (bez_target[Y_AXIS] + candidate_pos1);
166 166
       if (dist1(new_pos0, new_pos1, interp_pos0, interp_pos1) > (SIGMA)) break;
167 167
       new_t = candidate_t;
168 168
       new_pos0 = candidate_pos0;

Loading…
Cancel
Save