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)