# How can I create a normal vector pointing to the nearest point...

## Recommended Posts

Hi guys,

As you can see in the image below, I have some scattered points on a grid and there are some points near a curve that are selected.

Now I need help on how to create a "Normal vector" on each scattered point, that is toward (pointed to) the nearest point to the point selection.

Thanks for helping.

Edited by Masoud

##### Share on other sites

maybe this can be of same Help otherwise try to search For Slope example or Just describe what you want to do with them Points .. you can Use Ray also ...PArticles with Groups ..I'm more for visual motion explaining Example ..Don't know

new.hipnc

• 1
• 1

##### Share on other sites

you can do that with pointclouds, it's ideal for averaging out the normal directions
which is probably what you want.

```// wrangle1
// change color by proximity to curve points
int handle = pcopen(1,"P",@P,chf("radius"),1);
if(pcnumfound(handle)>0){
@Cd = {1,0,1};
}

// use blast nodes to separte in 2 geometries

// wrangle2
// create normals from average closest points
int handle = pcopen(1,"P",@P,chf("radius"),chi("maxpoints"));
if(pcnumfound(handle)>0){
vector p = pcfilter(handle,"P");
v@N = p-@P;
}```

> using 1 point or 40 points for position lookup

Edited by bunker
• 2

##### Share on other sites

Hi, dear Tesan and Julien,

You are excellent. Thanks for helping!

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account