pythonquadratic-programming

Calculate beam angel using throw distance and spot size


I am trying to figure out the formula on this link, and create a quadratic calculator that works each way basically. At this point I am only trying to calculate the beam angel using throw distance and spot size using the Full Width Half Maximum (FWHM) Angle method. I have a basic python program but my results are never similar to what this website calcualtes. I know its a long shot but any suggestions would be greatly appriciated:

import math
def calculate_beam_angle(throw_distance, spot_size):
    # Calculate the half-maximum angle
    half_max_angle = math.atan(spot_size / throw_distance)

    # Convert the half-maximum angle to degrees
    half_max_angle_degrees = math.degrees(half_max_angle)

    # Calculate the Full Width Half Maximum (FWHM) angle
    fwhm_angle = 2 * half_max_angle_degrees

    return fwhm_angle

# Example usage
throw_dist = float(input("Enter the throw distance (in inches): "))
spot_size = float(input("Enter the spot size (in inches): "))

beam_angle = calculate_beam_angle(throw_dist, spot_size)
print("The beam angle is", beam_angle, "degrees.")

e. g. I have 100 for throw distance and 50 for spot size and I should be getting 28.07 for beam angel. but using this program I am getting 53.


Solution

  • I am not sure where your script goes wrong, but this is how I would do the calculation

    import math
    def compute_beamAngle(throw_dist: float, spot_sze: float) -> float:
        # Use right triangle characteristics to compute beam angle
        a = math.degrees(math.atan((spot_sze/2)/throw_dist))
        return 2*a
    

    compute_beamAngle(100, 50) yields 28.072486935852957

    I think your error comes about because of the way you attempt to compute half_angle but am not sure.