raytraverse.translate¶
functions for translating between coordinate spaces and resolutions
-
raytraverse.translate.
uv2xy
(uv)[source]¶ translate from unit square (0,1),(0,1) to disk (x,y) http://psgraphics.blogspot.com/2011/01/improved-code-for-concentric -map.html.
-
raytraverse.translate.
uv2xyz
(uv, axes=0, 1, 2, xsign=1)[source]¶ translate from 2 x unit square (0,2),(0,1) to unit sphere (x,y,z) http://psgraphics.blogspot.com/2011/01/improved-code-for-concentric -map.html.
-
raytraverse.translate.
xyz2uv
(xyz, normalize=False, axes=0, 1, 2, flipu=False)[source]¶ translate from vector x,y,z (normalized) to u,v (0,2),(0,1) Shirley, Peter, and Kenneth Chiu. A Low Distortion Map Between Disk and Square. Journal of Graphics Tools, vol. 2, no. 3, Jan. 1997, pp. 45-52. Taylor and Francis+NEJM, doi:10.1080/10867651.1997.10487479.
-
raytraverse.translate.
skybin2xyz
(bn, side)[source]¶ generate source vectors from sky bins
- Parameters
bn (np.array) – bin numbers
side (int) – square side of discretization
- Returns
xyz – direction to center of sky patches
- Return type
np.array
-
raytraverse.translate.
xyz2xy
(xyz, axes=0, 1, 2, flip=False)[source]¶ xyz coordinates to xy mapping of angular fisheye proejection
-
raytraverse.translate.
tp2xyz
(thetaphi, normalize=True)[source]¶ calculate x,y,z vector from theta (0-pi) and phi (0-2pi) RHS Z-up
-
raytraverse.translate.
chord2theta
(c)[source]¶ compute angle from chord on unit circle
- Parameters
c (float) – chord or euclidean distance between normalized direction vectors
- Returns
theta – angle captured by chord
- Return type
float
-
raytraverse.translate.
theta2chord
(theta)[source]¶ compute chord length on unit sphere from angle
- Parameters
theta (float) – angle
- Returns
c – chord or euclidean distance between normalized direction vectors
- Return type
float
-
raytraverse.translate.
resample
(samps, ts=None, gauss=True, radius=None)[source]¶ simple array resampling. requires whole number multiple scaling.
- Parameters
samps (np.array) – array to resample along each axis
ts (tuple, optional) – shape of output array, should be multiple of samps.shape
gauss (bool, optional) – apply gaussian filter to upsampling
radius (float, optional) – when gauss is True, filter radius, default is the scale ratio - 1
- Returns
to resampled array
- Return type
np.array
-
raytraverse.translate.
rmtx_yp
(v)[source]¶ generate a pair of rotation matrices to transform from vector v to z, enforcing a z-up in the source space and a y-up in the destination. If v is z, returns pair of identity matrices, if v is -z returns pair of 180 degree rotation matrices.
- Parameters
v (array-like of size (N, 3)) – the vector direction representing the starting coordinate space
- Returns
ymtx, pmtx – two rotation matrices to be premultiplied in order to reverse transform, swap order and transpose.
- Return type
(np.array, np.array)
Notes
if N is one: Forward: (pmtx@(ymtx@xyz.T)).T or np.einsum(“ij,kj,li->kl”, ymtx, xyz, pmtx) Backward: (ymtx.T@(pmtx.T@xyz.T)).T or np.einsum(“ji,kj,il-kl”, pmtx, nv, ymtx) else: Forward: np.einsum(“vij,vkj,vli->vkl”, ymtx, xyz, pmtx) Backward: np.einsum(“vji,vkj,vil-vkl”, pmtx, nv, ymtx)
-
raytraverse.translate.
cull_vectors
(vecs, tol)[source]¶ return mask to cull duplicate vectors within tolerance
- Parameters
vecs (Union[cKDTree, np.array]) – prebuilt KDTree or np.array to build a new one. culling keeps first vector in array used to build tree.
tol (float) – tolerance for culling
- Returns
boolean mask of vecs (or vecs.data) to cull vectors
- Return type
np.array