import math def fixation_radius_normalized(theta_deg: float, distance_cm: float, screen_width_cm: float, screen_height_cm: float, resolution_x: int, resolution_y: int, method: str = "max"): """ Berechnet den PyGaze-Fixationsradius für normierte Gaze-Daten in [0,1]. """ # Schritt 1: visueller Winkel → physische Distanz (cm) delta_cm = 2 * distance_cm * math.tan(math.radians(theta_deg) / 2) # Schritt 2: physische Distanz → Pixel delta_px_x = delta_cm * (resolution_x / screen_width_cm) delta_px_y = delta_cm * (resolution_y / screen_height_cm) # Pixelradius if method == "max": r_px = max(delta_px_x, delta_px_y) else: r_px = math.sqrt(delta_px_x**2 + delta_px_y**2) # Schritt 3: Pixelradius → normierter Radius r_norm_x = r_px / resolution_x r_norm_y = r_px / resolution_y if method == "max": return max(r_norm_x, r_norm_y) else: return math.sqrt(r_norm_x**2 + r_norm_y**2) # Beispiel: 55" 4k Monitor screen_width_cm = 3*121.8 screen_height_cm = 68.5 resolution_x = 3*3840 resolution_y = 2160 distance_to_screen_cm = 120 method = 'max' max_angle= 1.0 maxdist_px = fixation_radius_normalized(theta_deg=max_angle, distance_cm=distance_to_screen_cm, screen_width_cm=screen_width_cm, screen_height_cm=screen_height_cm, resolution_x=resolution_x, resolution_y=resolution_y, method=method) print("PyGaze max_dist (max):", maxdist_px) method = 'euclid' maxdist_px = fixation_radius_normalized(theta_deg=max_angle, distance_cm=distance_to_screen_cm, screen_width_cm=screen_width_cm, screen_height_cm=screen_height_cm, resolution_x=resolution_x, resolution_y=resolution_y, method=method) print("PyGaze max_dist (euclid):", maxdist_px) # Passt noch nicht zu der Breite # https://osdoc.cogsci.nl/4.0/de/visualangle/ # https://reference.org/facts/Visual_angle/LUw29zy7