# Point Cloud Normals

## Recommended Posts

Hi!

I have a problem that is really stumping me. I have a large point cloud that comes from a 3D-scanner and I want to copy small boxes onto the points. But for this I need point-normals and i can´t figure out how to calculate the normals without primitives. If someone have an idea I would be deeply grateful.

##### Share on other sites
eetu    496

Try converting the point cloud into a volume (with large enough contribution from each particle), and then taking a volume gradient sample from the volume.

##### Share on other sites

I guess you've already tried this, but doesn't the point sop work in this case? add normal should do it, right?

##### Share on other sites
symek    266

I guess you've already tried this, but doesn't the point sop work in this case? add normal should do it, right?

The question I guess is not to add normals (you can always do that), but how this normals should look like. Volume Gradient will compute local density change at the point cloud border, so normals could point "outside" the point cloud.

edit: wouldn't be natural to just skin them, and transfer normals from skinned version back? Volume from a thin layer of point cloud might goes wrong...

Edited by SYmek

##### Share on other sites
ikarus    64

you you want to make sure your mesh is consistent use particle fluid surface instead of iso-offset/pointcloud

##### Share on other sites

hi,

Base of what Icarus said, here a hip file with a point cloud (from brekel kinect) where I transfer normal from a particle fluid object node to the points.

have fun

Thomas

NormalTransfert_v1.rar

##### Share on other sites
petz    306

you could do this by estimating tangent planes to your pointset. just calculate a covariance matrix and search for the eigenvectors with the lowest eigenvalue.

its fast and robust. the only drawback is that there is no way to define if the normals are pointing inside or outside for a general set of points. you could dot product the normals to the vector(camera - P) or use the centroid of your pointcloud to find the wrong oriented normals but this doesn´t work for all cases. and if it does not you´ll have to check normals of neighbouring points and reorient them.

hth.

petz

EDIT:

increase max_points to something around 100 in the example file!

normals1.hip

Edited by petz
• 2

##### Share on other sites
symek    266

thanks petz! I've never thought you can actually compute covariance in VEX... arrays make a difference!

skk.

##### Share on other sites

wow petz, far away to my mathematical skill !!

thk it opens my mind !

Thomas

##### Share on other sites
anim    589

very nice example petz

I've just added visualization node for normals, to see the effect

normals1_vis.hip

##### Share on other sites

hey it's me, what handsome guy, even though a little spotty

when we compare the lighting visualization with your scene Anim, between "transfert normal from particle fluid" and the "covariance matrix", the covariance's method gives much better results !

have fun,

Thomas

Edited by papicrunch

##### Share on other sites

WOW! Thank´s to everyone who has responded. This thread is the answer to all my questions I was going to ask.

Thank´s to Papicrunch for the file. I was on the way to do it like you did but could not get it to work. And thank you Anim for the idea to preview the points as particles.

And a big THANK´S to you Petz! You provided me again a solution that does exactly what I was looking for and again I don´t understand not a bit of it.

The best thing is that your example solves two problems for me. First off, it gives me the normals. And second: all these small steps and irregularities in my pointcloud are smoothed out if I use the "project_point" toggle.

Thank you very much!

Edited by resonanz

##### Share on other sites
petz    306

WOW! Thank´s to everyone who has responded. This thread is the answer to all my questions I was going to ask.

Thank´s to Papicrunch for the file. I was on the way to do it like you did but could not get it to work. And thank you Anim for the idea to preview the points as particles.

And a big THANK´S to you Petz! You provided me again a solution that does exactly what I was looking for and again I don´t understand not a bit of it.

The best thing is that your example solves two problems for me. First off, it gives me the normals. And second: all these small steps and irregularities in my pointcloud are smoothed out if I use the "project_point" toggle.

Thank you very much!

you´re welcome!

petz

##### Share on other sites
ikarus    64

thats some wizardry math right there, pure wizardry

##### Share on other sites
pclaes    233

I had a need for this recently and fixed some tiny vex issues in Petz file so it works with H12 in case anyone wants it.

normals2.hip

• 1

##### Share on other sites

Sorry for raking up this old topic but I am again in a situation where I need to calculate point normals for a huge 3D-scan dataset. This time it is very important to have the normals ALL pointing outward, what is not possible to achieve with this method (AFAIK). What would be the best way to get normals with consistent orientation?

##### Share on other sites
petz    306

well, it depends on the data. assuming you have a rather smooth pointcloud you could recursively check normals of neighbouring points and reorient them if necessary. it´s easy to implement and quite fast (hdk) but not always usable for more complex datasets. another option would be to mesh the pointset using a surface reconstruction algorithm (most probably power crust) this would be alot more work to implement, though...
however, since you need to code it in the hdk anyway you might want to take a look at pcl  (point cloud library). it does everything you need, and if i remember correctly, it is available even precompiled on their website.

petz