#
# Graph the light intensity from a one dimensional array of isotropic
# LEDs along a line parallel to the array of LEDs using gnuplot(1):
#
# For an isotropic light source a perpendicular distance, d, from a
# point, p, in a plane, the light intensity measured at a distance, l,
# from p in the plane would be proportional to the hypotenuse, h,
# squared, i.e.:
#
#     h^2 = d^2 + l^2
#     I is proportional to 1 / h^2
#     I is proportional to 1 / (d^2 + l^2), by substitution
#
#     If l = 0, (i.e., the reference value directly under the
#     isotropic light source):
#
#     I(0) = 1 / d^2
#     I(l) / I(0) = (1 / (d^2 + l^2)) / (1 / d^2)
#                 = d^2 / (d^2 + l^2)
#                 = 1 / (1 + (l^2 / d^2))
#
# Note that this value is the RELATIVE intensity of light at a
# distance l from the perpendicular under the light source in the
# plane, (i.e., relative to directly under the isotropic light
# source.) If l = 0, this value is unity.
#
# So, the value of the intensity of an isotropic light source, at a
# perpendicular distance, d, from a plane decreases at 1 / d^2. The
# RELATIVE intensity of light at a distance l in the plane to that
# value is 1 / (1 + (l^2 / d^2)), which is useful for calculating the
# variation in the intensity of light projected on the plane from an
# array of identical isotropic light sources.
#
# d = distance between LED array and parallel line, inches
#
# l = distance between LEDs, inches, (60 LEDs per meter for SMD 5050,
# which are approximated as an isotropic radiator)
#
d = 5
l = 39.37 / 60
#
set grid
show grid
#
set title "Relative Light Intensity, (to one isotropic LED)"
set xlabel "X, Inches"
set ylabel "Light Intensity"
#
# One LED:
#
plot [-15:15] 1 / (1 + (((x + (0 * l)) / d) ** 2)) title "One LED" with lines
#
# Linear array of 15 LEDs:
#
plot [-15:15] 1 / (1 + (((x + (-7 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-6 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-5 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-4 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-3 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-2 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-1 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+0 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+1 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+2 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+3 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+4 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+5 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+6 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+7 * l)) / d) ** 2)) \
              title "15 LEDs" with lines
#
# Linear array of 10 LEDs:
#
plot [-10:10] 1 / (1 + (((x + (-5 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-4 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-3 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-2 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (-1 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+0 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+1 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+2 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+3 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+4 * l)) / d) ** 2)) + \
              1 / (1 + (((x + (+5 * l)) / d) ** 2)) \
              title "10 LEDs" with lines
#
set terminal jpeg font "/usr/share/fonts/truetype/freefont/FreeSans.ttf,10"
set output "isotropic.array.jpg"
set terminal wxt
#
exit