# Normal Direction on a Square

## Recommended Posts

Hello,

I have a square consisting of several points on each side. I want the Normals to face outwards on each point. I used the expression \$BBX-\$BBZ in a point sop and got two of the sides doing exactly what I want, But I need it for the other two sides.

I have attached my scene file. Any help would be greatly appreciated.

Thanks

Normal_Direction_On_Square.hip

##### Share on other sites

We know we can get the type of normals you are looking for from a Facet following a box. But you only want a single square. So you can attribute transfer the normals from the box to the square after deleting all those extra box vertices.

Edited by Atom

##### Share on other sites

This is perfect. Thank you Atom !!

##### Share on other sites

or just use a point wrangle with this:

```v@center = set(0,0,0);
v@N = v@center - v@P;```

##### Share on other sites

Hi Michael, the code you shared gives a vector which points inwards to the origin at every point.

Here's my point wrangle code that gives normals at any point on the surface of a unit box. Given all the conditionals, I assume there is probably a much more succinct solution.

```vector onSurface1;
vector onSurface2;

if (@P.z == 0.5 || @P.z == -0.5) {
onSurface1 = set(-@P.y,@P.x,0);
onSurface2 = set(@P.y,@P.x,0);

@N = abs(normalize(cross(onSurface1,onSurface2)));
if(@P.z < 0) {  @N *= -1.0; }

} else if (@P.y == 0.5 || @P.y == -0.5) {
onSurface1 = set(-@P.z,0,@P.x);
onSurface2 = set(@P.z,0,@P.x);

@N = abs(normalize(cross(onSurface1,onSurface2)));
if(@P.y < 0) {  @N *= -1.0; }

} else {
onSurface1 = set(0,-@P.z,@P.x);
onSurface2 = set(0,@P.z,@P.x);

@N = abs(normalize(cross(onSurface1,onSurface2)));
if(@P.x < 0) {  @N *= -1.0; }
}```

##### Share on other sites

@rreno

mine was just for the OP specific case

##### Share on other sites

Oops I read square and thought box. Mine is totally useless for this situation then.

##### Share on other sites

Thank you all for the help !

## Create an account

Register a new account