// category custom "User Defined" function custom() {} // button custom.pythaghyp "Pythag [hyp]" custom.pythaghyp = (x, y) => { c = Math.max(x, y); a = Math.min(x, y); c2 = c * c; a2 = a * a; return Math.sqrt(c2 + a2); } // button custom.pythaglen "Pythag [len]" custom.pythaglen = (x, y) => { c = Math.max(x, y); a = Math.min(x, y); c2 = c * c; a2 = a * a; return Math.sqrt(c2 - a2); } // button custom.TurningRadius "Turning Radius" custom.TurningRadius = (wheelbase, pivotAngleDegrees) => { const pivotAngleRadians = pivotAngleDegrees * (Math.PI / 180); // Convert degrees to radians const radius = wheelbase / (2 * Math.sin(pivotAngleRadians / 2)); return radius; } // button custom.calculatePivotAngle "Pivot Angle" custom.calculatePivotAngle = (wheelbase, turningRadius) => { const sinHalfAngle = wheelbase / (2 * turningRadius); // Clamp the value to [-1, 1] to avoid NaN from floating-point rounding const clampedSin = Math.min(1, Math.max(-1, sinHalfAngle)); const halfAngleRadians = Math.asin(clampedSin); const fullAngleRadians = 2 * halfAngleRadians; const fullAngleDegrees = fullAngleRadians * (180 / Math.PI); return fullAngleDegrees; }