-1

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.

Nick Rahi
  • 3
  • 1
  • 1
    **DO NOT** post images of code, links to code, data, error messages, etc. - copy or type the text into the question. They can't be searched or copied, or even consumed by users of adaptive technologies like screen readers. – itprorh66 May 08 '23 at 17:20
  • there is no image on this post – Nick Rahi May 08 '23 at 23:58
  • I agree no images but certainly links to code and explanations which are not allowed. – itprorh66 May 09 '23 at 14:53
  • I dont understand, can ou please point out which sentence exactly is saying that, I am trying to understand what I did wrong with the famous beam angel calculator. I have a sample website and a sample code. what is not allowed? – Nick Rahi May 10 '23 at 01:13
  • You are using links to expected r5esults and links to the formulae which while they maybe helpful, you should also include a full explanation of what you are trying to accomplish and what results you expect without relying solely on links. – itprorh66 May 10 '23 at 14:00
  • sorry about that did you see below the code: 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. – Nick Rahi May 10 '23 at 16:28

1 Answers1

0

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.

itprorh66
  • 3,110
  • 4
  • 9
  • 21