geometry_utils
A set of helper utility functions for dealing with 3D geometry
check_points_in_cone(size, particle_positions)
Checks which points are within a cone with specified size @size.
NOTE: Assumes the cone and positions are expressed in the same coordinate frame such that the cone's height is aligned with the z-axis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
2 - array
|
(radius, height) dimensions of the cone, specified in its local frame |
required |
particle_positions
|
(N, 3) array
|
positions to check for whether it is in the cone |
required |
Returns:
| Type | Description |
|---|---|
N,) array
|
boolean numpy array specifying whether each point lies in the cone. |
Source code in OmniGibson/omnigibson/utils/geometry_utils.py
check_points_in_convex_hull_mesh(mesh_face_centroids, mesh_face_normals, particle_positions)
Checks which points are within a sphere with specified size @size.
NOTE: Assumes the mesh and positions are expressed in the same coordinate frame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh_face_centroids
|
(D, 3)
|
(x,y,z) location of the centroid of each mesh face, expressed in its local frame |
required |
mesh_face_normals
|
(D, 3)
|
(x,y,z) normalized direction vector of each mesh face, expressed in its local frame |
required |
particle_positions
|
(N, 3) array
|
positions to check for whether it is in the mesh |
required |
Returns:
| Type | Description |
|---|---|
N,) array
|
boolean numpy array specifying whether each point lies in the mesh |
Source code in OmniGibson/omnigibson/utils/geometry_utils.py
check_points_in_cube(size, particle_positions)
Checks which points are within a cube with specified size @size.
NOTE: Assumes the cube and positions are expressed in the same coordinate frame such that the cube's dimensions are axis-aligned with (x,y,z)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size float
|
length of each side of the cube, specified in its local frame |
required | |
particle_positions
|
(N, 3) array
|
positions to check for whether it is in the cube |
required |
Returns:
| Type | Description |
|---|---|
N,) array
|
boolean numpy array specifying whether each point lies in the cube. |
Source code in OmniGibson/omnigibson/utils/geometry_utils.py
check_points_in_cylinder(size, particle_positions)
Checks which points are within a cylinder with specified size @size.
NOTE: Assumes the cylinder and positions are expressed in the same coordinate frame such that the cylinder's height is aligned with the z-axis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
2 - array
|
(radius, height) dimensions of the cylinder, specified in its local frame |
required |
particle_positions
|
(N, 3) array
|
positions to check for whether it is in the cylinder |
required |
Returns:
| Type | Description |
|---|---|
N,) array
|
boolean numpy array specifying whether each point lies in the cylinder. |
Source code in OmniGibson/omnigibson/utils/geometry_utils.py
check_points_in_sphere(size, particle_positions)
Checks which points are within a sphere with specified size @size.
NOTE: Assumes the sphere and positions are expressed in the same coordinate frame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
float
|
radius dimensions of the sphere |
required |
particle_positions
|
(N, 3) array
|
positions to check for whether it is in the sphere |
required |
Returns:
| Type | Description |
|---|---|
N,) array
|
boolean numpy array specifying whether each point lies in the sphere |
Source code in OmniGibson/omnigibson/utils/geometry_utils.py
get_particle_positions_from_frame(pos, quat, scale, particle_positions)
Transforms particle positions @positions from the frame specified by @pos and @quat with new scale @scale.
This is similar to @get_particle_positions_in_frame, but does the reverse operation, inverting @pos and @quat
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
3 - array
|
(x,y,z) pos of the local frame |
required |
quat
|
4 - array
|
(x,y,z,w) quaternion orientation of the local frame |
required |
scale
|
3 - array
|
(x,y,z) local scale of the local frame |
required |
particle_positions
|
(N, 3) array
|
positions |
required |
Returns:
| Type | Description |
|---|---|
N,) array
|
updated particle positions in the parent coordinate frame |
Source code in OmniGibson/omnigibson/utils/geometry_utils.py
get_particle_positions_in_frame(pos, quat, scale, particle_positions)
Transforms particle positions @positions into the frame specified by @pos and @quat with new scale @scale, where @pos and @quat are assumed to be specified in the same coordinate frame that @particle_positions is specified
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
3 - array
|
(x,y,z) pos of the new frame |
required |
quat
|
4 - array
|
(x,y,z,w) quaternion orientation of the new frame |
required |
scale
|
3 - array
|
(x,y,z) local scale of the new frame |
required |
particle_positions
|
(N, 3) array
|
positions |
required |
Returns:
| Type | Description |
|---|---|
N,) array
|
updated particle positions in the new coordinate frame |
Source code in OmniGibson/omnigibson/utils/geometry_utils.py
wrap_angle(theta)
" Converts an angle to the range [-pi, pi).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
float
|
angle in radians |
required |
Returns:
| Type | Description |
|---|---|
float
|
angle in radians in range [-pi, pi) |