##### Blog
Go to start of banner

# points-grep to grep points

The existing points-grep utility has been given a major facelift. Given a shape as a set of planes, e.g. a bounding box or a hull of a moving vehicle, it greps points that belong to that shape from a streamed point cloud.

Let's make a dataset: just fill a cube with points:

`> for i in \$( seq -5 0.5 5 ) ; do for j in \$( seq -5 0.5 5 ) ; do for k in \$( seq -5 0.5 5 ) ; do echo \$i,\$j,\$k ; done ; done ; done > cube.csv`

Let's cut a slice from the cube, where 1,1,1,0.5 is 1,1,1 are coordinates of a normal to the plane and 0.5 it's distance from 0,0,0. (Normals do not need to be normalized.)

`> cat cube.csv | points-grep planes --normals <( echo 1,1,1,0.5 ) > filtered.csv`

View it:

`> view-points "cube.csv;colour=grey;hide" "filtered.csv;colour=red"` Specify multiple planes, e.g. grep octahedron:

`> cat cube.csv | points-grep planes --normals <( echo -1,-1,-1,2; echo -1,-1,1,2; echo -1,1,-1,2; echo -1,1,1,2; echo 1,-1,-1,2; echo 1,-1,1,2; echo 1,1,-1,2; echo 1,1,1,2; ) > filtered.csv`

Try to view the results as above.

Now, suppose we have a bounding box for a moving vehicle.

Let us prepare the dataset: the same cube, but we will merge it with the vehicle trajectory, which, for simplicity's sake will have only 3 vehicle positions given as x,y,z,roll,pitch,yaw. For each point of the cube, we will specify the corresponding position of the vehicle at the time, when the point was seen. (For demonstration's sake, I omit the usual timestamp manipulations and simply append the vehicle position to each point.)

`( cat cube.csv | csv-paste - value '-1,-1,-1,0.1,0.2,0.1,0' ; cat cube.csv | csv-paste - value '0,0,0,0.2,0.1,0.3,1' ; cat cube.csv | csv-paste - value '1,2,1,-0.1,-0.1,0.1,2' ) > merged.csv`

Filter the data:

`> cat merged.csv | points-grep box --size=1,2,3 --fields=x,y,z,filter > filtered.csv`

and view it, colouring the points by the vehicle position number:

`> view-points "cube.csv;colour=100,100,100,100" "filtered.csv;fields=x,y,z,,,,,,,id;weight=5" --orthographic` • No labels