Appendix D. Math Cheat Sheet

Sensors

Raw values to percentage (light sensor):

percentage = 146 - raw value / 7

Raw values to temperatures, in C° (temperature sensor):

C° = (785 - raw value) / 8

Conversion of Celsius to Fahrenheit degrees:

F° = C° x 9 / 5 + 32

Averages

Simple average:

A = (V, +V2+... +Vn)/n

Weighted average:

A = (V1xW,+V2xW2 + .,. + VnxWn) / (W, + W2 + ... + Wn)

Exponential smoothing:

An = (Vn xW, + An-1 x W2) / (W, + W2)

Interpolation

Linear interpolation: Find the value of the dependent variable Y for a given value of the independent variable X, knowing that for X equal to Xa, Y isYa, and for X equal to Xb, Y is Yb.

(Y - Ya) / (Yb - Ya) = (X - Xa) / (Xb - Xa)

Y = (X - Xa) x (Yb - Ya) / (Xb - Xa) + Ya

Equation of the straight line which connects ...

Get Building Robots with LEGO® Mindstorms® NXT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.