Monado OpenXR Runtime
m_optics.c File Reference

Functions related to field-of-view. More...

#include "math/m_mathinclude.h"
#include "math/m_api.h"
#include "util/u_debug.h"
#include <math.h>
#include <stdio.h>
#include <assert.h>
Include dependency graph for m_optics.c:

Macros

#define METERS_FORMAT   "%0.4fm"
 
#define DEG_FORMAT   "%0.1f deg"
 

Functions

static bool math_solve_triangle (double w_total, double w_1, double theta_total, double *out_theta_1, double *out_theta_2, double *out_d)
 Perform some of the computations from "Computing Half-Fields-Of-View from Simpler Display Models", to solve for the half-angles for a triangle where we know the center and total angle but not the "distance". More...
 
bool math_compute_fovs (double w_total, double w_1, double horizfov_total, double h_total, double h_1, double vertfov_total, struct xrt_fov *fov)
 Perform the computations from "Computing Half-Fields-Of-View from Simpler Display Models", to get half-FOVs from things we can retrieve from other APIs. More...
 

Detailed Description

Functions related to field-of-view.

Author
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..nosp@m.com

Function Documentation

◆ math_solve_triangle()

static bool math_solve_triangle ( double  w_total,
double  w_1,
double  theta_total,
double *  out_theta_1,
double *  out_theta_2,
double *  out_d 
)
static

Perform some of the computations from "Computing Half-Fields-Of-View from Simpler Display Models", to solve for the half-angles for a triangle where we know the center and total angle but not the "distance".

In the diagram below, the top angle is theta_total, the length of the bottom is w_total, and the distance between the vertical line and the left corner is w_1. out_theta_1 is the angle at the top of the left-most right triangle, out_theta_2 is the angle at the top of the right-most right triangle, and out_d is the length of that center vertical line, a logical "distance".

Any outparams that are NULL will simply not be set.

The triangle need not be symmetrical, despite how the diagram looks.

theta_total
*
theta_1 -> / | \ <- theta_2
/ | \
/ |d \
/ | \
-------------
[ w_1 ][ w_2 ]
[ --- w --- ]

Distances are in arbitrary but consistent units. Angles are in radians.

Returns
true if successful.

Referenced by math_compute_fovs().