Followup to float maths patch

This commit is contained in:
Scott Lahteine
2018-07-06 20:41:08 -05:00
parent b143441251
commit 63f4c9bdb9
5 changed files with 61 additions and 61 deletions

View File

@ -384,7 +384,7 @@ void MarlinSettings::postprocess() {
* M500 - Store Configuration
*/
bool MarlinSettings::save(PORTARG_SOLO) {
float dummy = 0.0f;
float dummy = 0;
char ver[4] = "ERR";
uint16_t working_crc = 0;
@ -466,7 +466,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(mesh_num_y);
EEPROM_WRITE(mbl.z_values);
#else // For disabled MBL write a default mesh
dummy = 0.0f;
dummy = 0;
const uint8_t mesh_num_x = 3, mesh_num_y = 3;
EEPROM_WRITE(dummy); // z_offset
EEPROM_WRITE(mesh_num_x);
@ -488,7 +488,7 @@ void MarlinSettings::postprocess() {
#if ABL_PLANAR
EEPROM_WRITE(planner.bed_level_matrix);
#else
dummy = 0.0f;
dummy = 0;
for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
#endif
@ -512,7 +512,7 @@ void MarlinSettings::postprocess() {
// For disabled Bilinear Grid write an empty 3x3 grid
const uint8_t grid_max_x = 3, grid_max_y = 3;
const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
dummy = 0.0f;
dummy = 0;
EEPROM_WRITE(grid_max_x);
EEPROM_WRITE(grid_max_y);
EEPROM_WRITE(bilinear_grid_spacing);
@ -550,7 +550,7 @@ void MarlinSettings::postprocess() {
_FIELD_TEST(x_endstop_adj);
// Write dual endstops in X, Y, Z order. Unused = 0.0
dummy = 0.0f;
dummy = 0;
#if ENABLED(X_DUAL_ENDSTOPS)
EEPROM_WRITE(endstops.x_endstop_adj); // 1 float
#else
@ -602,7 +602,7 @@ void MarlinSettings::postprocess() {
{
dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
EEPROM_WRITE(dummy); // Kp
dummy = 0.0f;
dummy = 0;
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
}
@ -848,7 +848,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(LIN_ADVANCE)
EEPROM_WRITE(planner.extruder_advance_K);
#else
dummy = 0.0f;
dummy = 0;
EEPROM_WRITE(dummy);
#endif
@ -870,7 +870,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(CNC_COORDINATE_SYSTEMS)
EEPROM_WRITE(gcode.coordinate_system); // 27 floats
#else
dummy = 0.0f;
dummy = 0;
for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_WRITE(dummy);
#endif
@ -885,7 +885,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(planner.xz_skew_factor);
EEPROM_WRITE(planner.yz_skew_factor);
#else
dummy = 0.0f;
dummy = 0;
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
#endif
@ -905,7 +905,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(dummy);
}
#else
dummy = 0.0f;
dummy = 0;
for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy);
#endif
@ -974,7 +974,7 @@ void MarlinSettings::postprocess() {
eeprom_error = true;
}
else {
float dummy = 0.0f;
float dummy = 0;
#if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) || ENABLED(NO_VOLUMETRICS)
bool dummyb;
#endif

View File

@ -157,22 +157,22 @@ float delta_safe_distance_from_top() {
*/
void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3) {
// Create a vector in old coordinates along x axis of new coordinate
const float p12[3] = { delta_tower[B_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[B_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z2 - z1 };
const float p12[3] = { delta_tower[B_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[B_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z2 - z1 },
// Get the reciprocal of Magnitude of vector.
const float d2 = sq(p12[0]) + sq(p12[1]) + sq(p12[2]), inv_d = RSQRT(d2);
d2 = sq(p12[0]) + sq(p12[1]) + sq(p12[2]), inv_d = RSQRT(d2),
// Create unit vector by multiplying by the inverse of the magnitude.
const float ex[3] = { p12[0] * inv_d, p12[1] * inv_d, p12[2] * inv_d };
ex[3] = { p12[0] * inv_d, p12[1] * inv_d, p12[2] * inv_d },
// Get the vector from the origin of the new system to the third point.
const float p13[3] = { delta_tower[C_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[C_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z3 - z1 };
p13[3] = { delta_tower[C_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[C_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z3 - z1 },
// Use the dot product to find the component of this vector on the X axis.
const float i = ex[0] * p13[0] + ex[1] * p13[1] + ex[2] * p13[2];
i = ex[0] * p13[0] + ex[1] * p13[1] + ex[2] * p13[2],
// Create a vector along the x axis that represents the x component of p13.
const float iex[3] = { ex[0] * i, ex[1] * i, ex[2] * i };
iex[3] = { ex[0] * i, ex[1] * i, ex[2] * i };
// Subtract the X component from the original vector leaving only Y. We use the
// variable that will be the unit vector after we scale it.
@ -190,13 +190,13 @@ void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3)
ex[1] * ey[2] - ex[2] * ey[1],
ex[2] * ey[0] - ex[0] * ey[2],
ex[0] * ey[1] - ex[1] * ey[0]
};
},
// We now have the d, i and j values defined in Wikipedia.
// Plug them into the equations defined in Wikipedia for Xnew, Ynew and Znew
const float Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + d2) * inv_d * 0.5,
Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + sq(i) + j2) * 0.5 - i * Xnew) * inv_j,
Znew = SQRT(delta_diagonal_rod_2_tower[A_AXIS] - HYPOT2(Xnew, Ynew));
Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + d2) * inv_d * 0.5,
Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + sq(i) + j2) * 0.5 - i * Xnew) * inv_j,
Znew = SQRT(delta_diagonal_rod_2_tower[A_AXIS] - HYPOT2(Xnew, Ynew));
// Start from the origin of the old coordinates and add vectors in the
// old coords that represent the Xnew, Ynew and Znew to find the point

View File

@ -1317,7 +1317,7 @@ void Planner::check_axes_activity() {
* Return 1.0 with volumetric off or a diameter of 0.0.
*/
inline float calculate_volumetric_multiplier(const float &diameter) {
return (parser.volumetric_enabled && diameter) ? RECIPROCAL(CIRCLE_AREA(diameter * 0.5f)) : 1;
return (parser.volumetric_enabled && diameter) ? 1.0f / CIRCLE_AREA(diameter * 0.5f) : 1;
}
/**