Zephyr Scientific Library (zscilib)
Files | Functions
Optics

Optics functions. More...

Files

file  optics.h
 API header file for optics in zscilib.
 

Functions

int zsl_phy_opt_refrac_index (zsl_real_t v, zsl_real_t *n)
 Calculates index of refraction of a medium based on the velocity of light in the medium. More...
 
int zsl_phy_opt_snell (zsl_real_t n1, zsl_real_t n2, zsl_real_t o1, zsl_real_t *o2)
 Calculates the angle of refraction of a light beam changing the medium of propagation based on the incident angle and the index of refraction of both mediums. More...
 
int zsl_phy_opt_focus (zsl_real_t sr, zsl_real_t si, zsl_real_t *f)
 Calculates the distance of the focus of a curved mirror based on the position of the real (sr) and imaginary (si) images. More...
 
int zsl_phy_opt_critic_angle (zsl_real_t n1, zsl_real_t n2, zsl_real_t *oc)
 Calculates the critical angle of incision from which the refraction effect does not occur. More...
 
int zsl_phy_opt_power (zsl_real_t f, zsl_real_t *p)
 Calculates the power of a lens based on its focal length. More...
 
int zsl_phy_opt_magn (zsl_real_t y1, zsl_real_t y2, zsl_real_t *m)
 Calculates the magnification of a lens based on the real length of an object and its apparent length through the lens. More...
 
int zsl_phy_opt_dif (uint8_t n, zsl_real_t lambda, zsl_real_t o, zsl_real_t *d)
 Calculates the distance between two objects when a light beam of wavelength comparable to the distance passes through them and difracts producing spectral lines. More...
 

Detailed Description

Optics functions.

Function Documentation

◆ zsl_phy_opt_critic_angle()

int zsl_phy_opt_critic_angle ( zsl_real_t  n1,
zsl_real_t  n2,
zsl_real_t oc 
)

Calculates the critical angle of incision from which the refraction effect does not occur.

Parameters
n1Index of refraction of the first medium.
n2Index of refraction of the second medium.
ocPointer to the output critical angle in radians. Will be set to NAN if any of the indexes is negative or if n2 > n1.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_opt_dif()

int zsl_phy_opt_dif ( uint8_t  n,
zsl_real_t  lambda,
zsl_real_t  o,
zsl_real_t d 
)

Calculates the distance between two objects when a light beam of wavelength comparable to the distance passes through them and difracts producing spectral lines.

Parameters
nNumber of the spectral line.
lambdaWavelength of the light beam in nanometers.
oAngle between the center of the distance and the n-th spectral line in radians.
dPointer to the output distance in nanometers. Will be set to NAN if either 'n', 'lambda' or sin(o) are negative or if sin(o) = 0.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_opt_focus()

int zsl_phy_opt_focus ( zsl_real_t  sr,
zsl_real_t  si,
zsl_real_t f 
)

Calculates the distance of the focus of a curved mirror based on the position of the real (sr) and imaginary (si) images.

Parameters
srDistance to the real image in meters.
siDistance to the imaginary image in meters.
fPointer to the output distance to the focus in meters. Will be set to NAN if the mirror is plane AKA sr + si = 0.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_opt_magn()

int zsl_phy_opt_magn ( zsl_real_t  y1,
zsl_real_t  y2,
zsl_real_t m 
)

Calculates the magnification of a lens based on the real length of an object and its apparent length through the lens.

Parameters
y1Real length of the object in meters.
y2Apparent length of the object in meters.
mPointer to the output magnification value. Will be set to NAN if any of the input values is negative of if y1 = 0.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_opt_power()

int zsl_phy_opt_power ( zsl_real_t  f,
zsl_real_t p 
)

Calculates the power of a lens based on its focal length.

Parameters
fFocal length in meters.
pPointer to the output power in 1 / meter. Will be set to NAN if f = 0.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_opt_refrac_index()

int zsl_phy_opt_refrac_index ( zsl_real_t  v,
zsl_real_t n 
)

Calculates index of refraction of a medium based on the velocity of light in the medium.

Parameters
vVelocity of light in the medium in meters per second.
nPointer to the output index of refraction. Will be set to NAN if the velocity is negative or greater than the speed of light.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_opt_snell()

int zsl_phy_opt_snell ( zsl_real_t  n1,
zsl_real_t  n2,
zsl_real_t  o1,
zsl_real_t o2 
)

Calculates the angle of refraction of a light beam changing the medium of propagation based on the incident angle and the index of refraction of both mediums.

Parameters
n1Index of refraction of the first medium.
n2Index of refraction of the second medium.
o1Angle of incision in radians.
o2Pointer to the output angle of refraction in radians. Will be set to NAN if any of the indexes is negative or if the light beam does not change of medium.
Returns
0 if everything executed properly, error code on failure.