Jump to content

How could I expand border edges..?


Masoud

Recommended Posts

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
Link to comment
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
Link to comment
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)

 

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...