====== Using a point cloud to validate a simulation ======
===== Idea =====
The idea is to take a point cloud of a measured tree and 'move it over' it on the simulated tree to see how similar the tree and the measurements are. In the following, the point cloud (shown in the figure below) has been artificially created and therefore fits the tree very well.
|{{ :tutorials:valid_pc.png?600 | }}|
|Generated example point cloud and two models with 99% and 85% accuracy|
The example model can be found in the [[https://gallery.grogra.de/project_gallery/6728954ce2f11365175b52ba|GroIMP gallery]]
===== Steps =====
- Import the point cloud as a graph into the growth model. (see [[tutorials:pointcloud-io|here]])
- Grow the model to the right size (e.g. the age of the measured plant)
- Build the mathematical volume of the simulated plant
- Querying the points of the point cloud to estimate the coverage of the model
===== Generating a volume =====
A volume in GroIMP can be handled with most operators known from set theory, os it is also possible to create a union of two volumes by using the logical or operator: ''|''. This can be used to create one volume from all elements of the simulation with a simple query:
Volume v = volume(first((*F*)));
[
f:F ::> {v = v | volume(f);}
]
===== Counting the points =====
A volume in GroIMP comes with a contains function that checks if a point is contained in the volume.
This can be used in an XL query to count all points contained in the volume created above:
long inside = count((*p:Point,(v.contains(p,false)==true)*));
long total = count((*Point*));
println((float)inside/(float)total);
The output from the last line above produces the relative proportions of points inside the simulated structure.
This approach can easily be extended to bounding boxes or more abstract shapes.