geometry_utils
A set of helper utility functions for dealing with 3D geometry
check_points_in_cone(size, pos, quat, scale, 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 |
pos
|
3 - array
|
(x,y,z) local location of the cone |
required |
quat
|
4 - array
|
(x,y,z,w) local orientation of the cone |
required |
scale
|
3 - array
|
(x,y,z) local scale 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/utils/geometry_utils.py
check_points_in_convex_hull_mesh(mesh_face_centroids, mesh_face_normals, pos, quat, scale, 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 |
pos
|
3 - array
|
(x,y,z) local location of the mesh |
required |
quat
|
4 - array
|
(x,y,z,w) local orientation of the mesh |
required |
scale
|
3 - array
|
(x,y,z) local scale of the cube, specified 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/utils/geometry_utils.py
check_points_in_cube(size, pos, quat, scale, 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 |
pos
|
3 - array
|
(x,y,z) local location of the cube |
required |
quat
|
4 - array
|
(x,y,z,w) local orientation of the cube |
required |
scale
|
3 - array
|
(x,y,z) local scale 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/utils/geometry_utils.py
check_points_in_cylinder(size, pos, quat, scale, 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 |
pos
|
3 - array
|
(x,y,z) local location of the cylinder |
required |
quat
|
4 - array
|
(x,y,z,w) local orientation of the cylinder |
required |
scale
|
3 - array
|
(x,y,z) local scale of the cube, 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/utils/geometry_utils.py
check_points_in_sphere(size, pos, quat, scale, 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 |
pos
|
3 - array
|
(x,y,z) local location of the sphere |
required |
quat
|
4 - array
|
(x,y,z,w) local orientation of the sphere |
required |
scale
|
3 - array
|
(x,y,z) local scale of the sphere, specified in its local frame |
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/utils/geometry_utils.py
generate_points_in_volume_checker_function(obj, volume_link, use_visual_meshes=True, mesh_name_prefixes=None)
Generates a function for quickly checking which of a group of points are contained within any container volumes. Four volume types are supported: "Cylinder" - Cylinder volume "Cube" - Cube volume "Sphere" - Sphere volume "Mesh" - Convex hull volume
@volume_link should have any number of nested, visual-only meshes of types {Sphere, Cylinder, Cube, Mesh} with naming prefix "container[...]"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
EntityPrim
|
Object which contains @volume_link as one of its links |
required |
volume_link
|
RigidPrim
|
Link to use to grab container volumes composing the values for checking the points |
required |
use_visual_meshes
|
bool
|
Whether to use @volume_link's visual or collision meshes to generate points fcn |
True
|
mesh_name_prefixes
|
None or str
|
If specified, specifies the substring that must exist in @volume_link's mesh names in order for that mesh to be included in the volume checker function. If None, no filtering will be used. |
None
|
Returns:
Type | Description |
---|---|
2 - tuple
|
where @in_range is a N-array boolean numpy array, (True where the particle is in the volume), and @particle_positions is a (N, 3) array specifying the particle positions in global coordinates
where @vol is the total volume being checked (expressed in global scale) aggregated across all container sub-volumes |
Source code in omnigibson/utils/geometry_utils.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
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/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 |