Jump to content

Normal Direction on a Square


logix1390

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

Link to comment
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
Link to comment
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; }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...