Jump to content
Sign in to follow this  
Masoud

How could I expand border edges..?

Recommended Posts

How could I expand border edges, without adding more points to my geometry?
As you can see in image bellow, I tried “PolyExtrude SOP” but it adds more points to my geometry.

 

Border.jpg

Share this post


Link to post
Share on other sites

Group the edge then Peak SOP and transform by normals?

Share this post


Link to post
Share on other sites
29 minutes ago, kleer001 said:

Group the edge then Peak SOP and transform by normals?

that would work for the straight bits, but for the corners you would have to increase the magnitude by which you move them to maintain the angles.

from the top of my head.. I think it was dividing the offset by either the cosine of the angle, or the cosine of half the angle.
So an offset at the corner, at 45 degrees would be 1/cos(45deg) which is 1/0.70710678118 = 1.41421356237 if my memory serves me right.
Which makes sense, as that is the square root of 2, and pythagoras and stuff :P

Edited by acey195

Share this post


Link to post
Share on other sites
8 hours ago, konstantin magnus said:

After extruding try:

Fuse: Snap -> Distance -> Greatest Point Number

Fuse: Consolidate 

expand.hiplc

I don't want to use PolyExtrude because it adds points to my geo.

Share this post


Link to post
Share on other sites

So, is there any practical solution?

Edited by Masoud

Share this post


Link to post
Share on other sites

You could also loop over the outer points with a detail wrangle:

int pts_grp[] = expandpointgroup(0, 'outer');
int total = len(pts_grp);

for(int i = 0; i < total; i++){
    int pt_prev = pts_grp[ (i - 1) % total ];
    int pt_curr = pts_grp[ i ];
    int pt_next = pts_grp[ (i + 1) % total ];
    
    vector next = normalize( point(0, 'P', pt_next) - point(0, 'P', pt_curr) ); 
    vector prev = normalize( point(0, 'P', pt_curr) - point(0, 'P', pt_prev) ); 

    vector avg  = normalize(next + prev);
    vector up = {0, 1, 0};
    vector in   = cross(avg, up);
    float dist  = dot(next, avg);
    vector dir  = in / dist;
    
    vector offset = dir * -chf('extrude');  
    setpointattrib(0, 'P', pt_curr, offset, 'add');
}

Forked from: https://forums.odforce.net/topic/41356-polyextrude-in-vex/

expand_3.hiplc

  • Like 1

Share this post


Link to post
Share on other sites

Yeah Konstatin's version is basically a worked out version of my ramblings.
Forgot to note that the dot product of 2 vectors is equal to the cosine of the angle between those vectors, making the code kind of convenient :)

@konstantin magnus Just realised you got this technique from the genius himself too :D (in the other thread)

 

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  

×