Module coords

Source
Expand description

S2 Coordinates

Structs§

ST
Convert a direction vector (not necessarily unit length) to an (s,t) point.
UV
A U-V coordinate pair.

Enums§

S2Projection
We have implemented three different projections from cell-space (s,t) to cube-space (u,v): linear, quadratic, and tangent. They have the following tradeoffs:

Constants§

K_LIMIT_IJ
The maximum index of a valid leaf cell plus one. The range of valid leaf cell indices is [0..kLimitIJ-1].
K_MAX_CELL_LEVEL
This is the number of levels needed to specify a leaf cell. This constant is defined here so that the S2::Metric class and the conversion functions below can be implemented without including s2cell_id.h. Please see s2cell_id.h for other useful constants and conversion functions.
K_MAX_SI_TI
The maximum value of an si- or ti-coordinate. The range of valid (si,ti) values is [0..kMaxSiTi].
ST_TO_UV
The default projection is quadratic
UV_TO_ST
The default projection is quadratic

Functions§

face_si_ti_to_xyz
Convert (face, si, ti) coordinates to a direction vector (not necessarily unit length).
face_uv_to_xyz
Convert (face, u, v) coordinates to a direction vector (not necessarily unit length).
face_xyz_to_uv
If the dot product of p with the given face normal is positive, set the corresponding u and v values (which may lie outside the range [-1,1]) and return true. Otherwise return false.
face_xyz_to_uvw
Transform the given point P to the (u,v,w) coordinate frame of the given face (where the w-axis represents the face normal).
get_face
Return the face containing the given direction vector. (For points on the boundary between faces, the result is arbitrary but repeatable.)
get_norm
Return the unit-length normal for the given face.
get_u_axis
Return the u-axis for the given face.
get_u_norm
Return the right-handed normal (not necessarily unit length) for an edge in the direction of the positive v-axis at the given u-value on the given face. (This vector is perpendicular to the plane through the sphere origin that contains the given edge.)
get_uvw_axis
Return the given axis of the given face (u=0, v=1, w=2).
get_uvw_face
With respect to the (u,v,w) coordinate system of a given face, return the face that lies in the given direction (negative=0, positive=1) of the given axis (u=0, v=1, w=2). For example, GetUVWFace(4, 0, 1) returns the face that is adjacent to face 4 in the positive u-axis direction.
get_v_axis
Return the v-axis for the given face.
get_v_norm
Return the right-handed normal (not necessarily unit length) for an edge in the direction of the positive u-axis at the given v-value on the given face.
ij_to_st
Convert the i- or j-index of a leaf cell to the minimum corresponding s- or t-value contained by that cell. The argument must be in the range [0..2**30], i.e. up to one position beyond the normal range of valid leaf cell indices.
invert_bits
invert the i and j axes
si_ti_to_st
Convert an si- or ti-value to the corresponding s- or t-value.
st_to_ij
Return the i- or j-index of the leaf cell containing the given s- or t-value. If the argument is outside the range spanned by valid leaf cell indices, return the index of the closest valid leaf cell (i.e., return values are clamped to the range of valid leaf cell indices).
st_to_si_ti
Return the si- or ti-coordinate that is nearest to the given s- or t-value. The result may be outside the range of valid (si,ti)-values.
st_to_uvlinear
Convert an s- or t-value to the corresponding u- or v-value. This is a non-linear transformation from [0,1] to [-1,1] that attempts to make the cell sizes more uniform.
st_to_uvquadratic
Convert an s- or t-value to the corresponding u- or v-value. This is a non-linear transformation from [0,1] to [-1,1] that attempts to make the cell sizes more uniform.
st_to_uvtan
Convert an s- or t-value to the corresponding u- or v-value. This is a non-linear transformation from [0,1] to [-1,1] that attempts to make the cell sizes more uniform.
swap_axes
swap the i and j axes
tile_xy_from_st_zoom
Convert an s-t-zoom coordinate to a tile coordinate returns the tile X-Y coordinate
tile_xy_from_uv_zoom
Convert an u-v-zoom coordinate to a tile coordinate returns the tile X-Y coordinate
to_face_st
Convert an S2Point to an (s,t) point.
to_face_uv
Convert an S2Point to an (u,v) point.
uv_to_st_quadratic
The inverse of the STtoUV transformation. Note that it is not always true that UV_TO_ST(STtoUV(x)) == x due to numerical errors.
uv_to_st_tan
The inverse of the STtoUV transformation. Note that it is not always true that UV_TO_ST(STtoUV(x)) == x due to numerical errors.
uv_to_stlinear
The inverse of the STtoUV transformation. Note that it is not always true that UV_TO_ST(STtoUV(x)) == x due to numerical errors.
valid_face_xyz_to_uv
Given a valid face for the given point p (meaning that dot product of p with the face normal is positive), return the corresponding u and v values (which may lie outside the range [-1,1]). Returns (pu, pv).
xyz_to_face_si_ti
Convert a direction vector (not necessarily unit length) to (face, si, ti) coordinates and, if p is exactly equal to the center of a cell, return the level of this cell (31 otherwise as its outside the bounds of levels). Return (face, zoom, si, ti).
xyz_to_face_st
Convert a direction vector (not necessarily unit length) to (face, u, v) coordinates. Returns (face, ps, pt)
xyz_to_face_uv
Convert a direction vector (not necessarily unit length) to (face, u, v) coordinates. Returns (face, pu, pv)