raytraverse.mapper

SpaceMapper

class raytraverse.mapper.SpaceMapper(dfile, ptres=1.0, rotation=0.0, tolerance=1.0)[source]

Bases: object

translate between world coordinates and normalized UV space

rotation = None

ccw rotation (in degrees) for point grid on plane

Type

float

tolerance = None

tolerance for point search when using point list for area

Type

float

ptres = None

point resolution for area

Type

float

property pt_kd

point kdtree for spatial queries built at first use

property sf

bbox scale factor

property ptshape

shape of point grid

property npts

number of points

property bbox

boundary frame for translating between coordinates [[xmin ymin zmin] [xmax ymax zmax]]

Type

np.array

_ro_pts(points, rdir=- 1)[source]

rotate points

Parameters
  • points (np.ndarray) – world coordinate points of shape (N, 3)

  • rdir (-1 or 1) –

    rotation direction:

    -1 to rotate from uv space 1 to rotate to uvspace

uv2pt(uv)[source]

convert UV –> world

Parameters

uv (np.array) – normalized UV coordinates of shape (N, 2)

Returns

pt – world xyz coordinates of shape (N, 3)

Return type

np.array

pt2uv(xyz)[source]

convert world –> UV

Parameters

xyz (np.array) – world xyz coordinates, shape (N, 3)

Returns

uv – normalized UV coordinates of shape (N, 2)

Return type

np.array

idx2pt(idx)[source]
pts()[source]
in_area(xyz)[source]

check if point is in boundary path

Parameters

xyz (np.array) – uv coordinates, shape (N, 3)

Returns

mask – boolean array, shape (N,)

Return type

np.array

_rad_scene_to_bbox(plane)[source]

SpaceMapperPt

class raytraverse.mapper.SpaceMapperPt(dfile, ptres=1.0, rotation=0.0, tolerance=1.0)[source]

Bases: raytraverse.mapper.spacemapper.SpaceMapper

translate between world coordinates and normalized UV space

property sf

bbox scale factor

property ptshape

shape of point grid

property bbox

bounding box

Type

np.array of shape (3,2)

uv2pt(uv)[source]

convert UV –> world

Parameters

uv (np.array) – normalized UV coordinates of shape (N, 2)

Returns

pt – world xyz coordinates of shape (N, 3)

Return type

np.array

pt2uv(xyz)[source]

convert world –> UV

Parameters

xyz (np.array) – world xyz coordinates, shape (N, 3)

Returns

uv – normalized UV coordinates of shape (N, 2)

Return type

np.array

idx2pt(idx)[source]
pts()[source]
in_area(xyz)[source]

check if point is in boundary path

Parameters

xyz (np.array) – uv coordinates, shape (N, 3)

Returns

mask – boolean array, shape (N,)

Return type

np.array

ViewMapper

class raytraverse.mapper.ViewMapper(dxyz=0.0, 1.0, 0.0, viewangle=360.0, name='view', mtxs=None, imtxs=None)[source]

Bases: object

translate between world and normalized UV space based on direction and view angle

Parameters
  • dxyz (tuple, optional) – central view direction

  • viewangle (float, optional) – if < 180, the horizontal and vertical view angle, if greater, view becomes 360,180

property viewangle

view angle

property ymtx

yaw rotation matrix (to standard z-direction y-up)

property pmtx

pitch rotation matrix (to standard z-direction y-up)

property bbox

bounding box of view

Type

np.array of shape (2,2)

property sf

bbox scale factor

property ivm

viewmapper for opposite view direction (in case of 360 degree view

property dxyz

(float, float, float) central view direction

view2world(xyz, i=0)[source]
world2view(xyz, i=0)[source]
xyz2uv(xyz, i=0)[source]
uv2xyz(uv, i=0)[source]
xyz2xy(xyz, i=0)[source]
pixelrays(res, i=0)[source]
ray2pixel(xyz, res, i=0)[source]
pixel2ray(pxy, res, i=0)[source]
pixel2omega(pxy, res)[source]
ctheta(vec, i=0)[source]
radians(vec, i=0)[source]
degrees(vec, i=0)[source]
in_view(vec, i=0, indices=True)[source]