The class intended to place spheres in space and identify if there are spheres around. It is important for random objects generating and avoiding self-intersection of objects.
More...
#include <CoreAPI.h>
|
| | SphericalCollision (float cellsize) |
| | create the collision space
|
| |
| void | setUnit (float u) |
| | set the cell size, the cell space should be empty
|
| |
|
void | clear () |
| | remove all spheres
|
| |
| int | addSphere (const vec3 &p, float radius) |
| | add the sphere into the space
|
| |
| vec3 | collides (const vec3 &p, float radius) |
| | check if sphere intersects other spheres in the space
|
| |
| vec4 | sphere (int idx) |
| | get the sphere parameters by index
|
| |
The class intended to place spheres in space and identify if there are spheres around. It is important for random objects generating and avoiding self-intersection of objects.
- Examples
- TreesGenerator.cpp.
◆ SphericalCollision()
| coat::SphericalCollision::SphericalCollision |
( |
float | cellsize | ) |
|
create the collision space
- Parameters
-
| cellsize | the cell size that should be approximately around the average sphere size |
◆ addSphere()
| int coat::SphericalCollision::addSphere |
( |
const vec3 & | p, |
|
|
float | radius ) |
add the sphere into the space
- Parameters
-
| p | the position |
| radius | the radius |
- Returns
- the sphere index, you may refer it later using the spher(index) function
- Examples
- TreesGenerator.cpp.
◆ collides()
| vec3 coat::SphericalCollision::collides |
( |
const vec3 & | p, |
|
|
float | radius ) |
check if sphere intersects other spheres in the space
- Parameters
-
- Returns
- the repelling force, it is zero if no collision happened.
- Examples
- TreesGenerator.cpp.
◆ setUnit()
| void coat::SphericalCollision::setUnit |
( |
float | u | ) |
|
set the cell size, the cell space should be empty
- Parameters
-
| u | the cell size that should be approximately around the average sphere size |
◆ sphere()
| vec4 coat::SphericalCollision::sphere |
( |
int | idx | ) |
|
get the sphere parameters by index
- Parameters
-
| idx | the sphere index (previously returned by addSphere) |
- Returns
- the position (xyz) and radius (w) as vec4
The documentation for this class was generated from the following file: