raytraverse.translate

functions for translating between coordinate spaces and resolutions

raytraverse.translate.norm(v)[source]

normalize 2D array of vectors along last dimension

raytraverse.translate.norm1(v)[source]

normalize flat vector

raytraverse.translate.tpnorm(thetaphi)[source]

normalize angular vector to 0-pi, 0-2pi

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=True)[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.xyz2xy(xyz, axes=0, 1, 2, flip=True)[source]
raytraverse.translate.pxy2xyz(pxy, viewangle=180.0)[source]
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.xyz2tp(xyz)[source]

calculate theta (0-pi), phi from x,y,z RHS Z-up

raytraverse.translate.tp2uv(thetaphi)[source]

calculate UV from theta (0-pi), phi

raytraverse.translate.uv2tp(uv)[source]

calculate theta (0-pi), phi from UV

raytraverse.translate.uv2ij(uv, side)[source]
raytraverse.translate.uv2bin(uv, side)[source]
raytraverse.translate.bin2uv(bn, side)[source]
raytraverse.translate.bin_borders(sb, side)[source]
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.interpolate2d(a, s)[source]
raytraverse.translate.rmtx_elem(theta, axis=2, degrees=True)[source]
raytraverse.translate.rotate_elem(v, theta, axis=2, degrees=True)[source]
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 (3,)) – the vector direction representing the starting coordinate space

Returns

ymtx, pmtx – two rotation matrices to be premultiplied in order to reverse transorm, swap order and transpose. Forward: pmtx@(ymtx@xyz.T)).T Backward: ymtx.T@(pmtx.T@xyz.T)).T

Return type

(np.array, np.array)

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.aa2xyz(aa)[source]
raytraverse.translate.xyz2aa(xyz)[source]