Jump to content
Sign in to follow this  
logix1390

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 this post


Link to post
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.

ap_normals_attrib_transfer.hipnc

Untitled-1.jpg

Edited by Atom

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×