Jump to content

How to calculate edge normal like PolyExtrude


bastian

Recommended Posts

Hello there!

How would you calculate the vector depicted as the red arrows in the image.

PolyExtrude node uses it when given an unshared edge group.

I've tried a polyframe's tangentu and tangent crossed in vex with the Normal. Without luck.

It doesn't seem to be just a continuation of each points inner edges (the not unshared ones.... :/ ). But can't wrap my head around where to go with it.

Thanks

mausvgvcpdia1.png

Edited by bastian
Link to comment
Share on other sites

@bastian
Prim wrangle (tangent)
 

int vtc[];
vtc = primvertices(0, @primnum);

int n = len(vtc);
int jm1, j, jp1;
int pm1, p, pp1;
vector A,B;
for (int i = 0; i < n; i++)
{
    jm1 = i - 1;
    j = i;
    jp1 = i + 1;
    if (chi('mode') == 0)
    {
        jm1 %= (n-1);
        jp1 %= (n-1);
    } else
    {
        jm1 = max(0, jm1);
        jp1 = min(n-1, jp1);
    }
    pm1 = vertexpoint(0, vtc[jm1]);
    p = vertexpoint(0, vtc[j]);
    pp1 = vertexpoint(0, vtc[jp1]);
    
    A = point(0, 'P', p) - point(0, 'P', pm1);
    B = point(0, 'P', pp1) - point(0, 'P', p);
    setpointattrib(0, 'tangentu', p, normalize(lerp(A, B, 0.5))); 
}

Point wrang-set normal by tangent
 

vector up = chv('up');

v@N = normalize(cross(v@tangentu, up));

if (chi('reverse'))
{
    v@N *= -1;
}

 

  • Like 1
Link to comment
Share on other sites

So I tried your suggestions and both don't work on corners and place where two edges meet, or on edges "facing upwards".
The picture in the post doesn't quite show how inconsistent the mesh is. My mistake.

I've done another pretty "hacky" way of just doing a extra PolyExtrude, wrangle a vector to the extruded edge.
But can imagine it breaking easily with a denser mesh.

I can definitely work with the results here, but would love a consistent method as it isn't the first time I've come across this problem.
Thanks again!

2023-02-16_11-36.png

2023-02-16_11-37.png

2023-02-16_11-39.png

Edited by bastian
comprehension
Link to comment
Share on other sites

Hi,

it seems to work this way:

For each point -> loop over all neighbours where the edge is an open edge. Calculate the cross product of the normal (of incident primitive of the half-edge) and the half-edge direction. Take the average of both normals.

VectorFromPolyExtrude_mod.hipnc

Edited by Aizatulin
  • Thanks 1
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...