How to expand/shrink curve?

   2162   4   0
User Avatar
Member
44 posts
Joined: April 2017
Offline
Hi! I have closed curve of complex curvature. I want to expand/shrink it by certain value, so I could get exactly same curve inside, and then outside of the original, respecting same distance to the original curve.

The problem is, that by default, normal is facing down.

I tried calculating new normal like that:

vector min,max,centre;
float amount = 0.255;
getbbox(min,max);
centre = (min+max)/2;
@N = (normalize(centre-@P));

This "kinda" works, but if I do then

@P += @N

point are shifted not evenly, because shape itself is not symmetric.

What is the right way to approach this tasks?

Because the shape is 2D, and its closed, I know there has to be a way to move each point inner/outward evenly, so they all respect same distance to the original curve.

Attachments:
shrink.png (437.7 KB)

User Avatar
Member
118 posts
Joined: Aug. 2017
Offline
hm

int previousPt = (@ptnum - 1 + @numpt) % @numpt;
 int currentPt = @ptnum;
 int nextPt = (@ptnum + 1) % @numpt;
 
 
 vector previousDir = point(geoself(), "P", previousPt) - point(geoself(), "P", currentPt);
 previousDir = normalize(previousDir);
 
 
 vector nextDir = point(geoself(), "P", nextPt) - point(geoself(), "P", currentPt);
 nextDir = normalize(nextDir);    
     

 float radian = acos(dot(previousDir, nextDir));
 

 vector centerDir = normalize(nextDir + previousDir);

 if (cross(nextDir, previousDir).y <= 0) {
     centerDir = -centerDir; 
 } 
 

 float r = chf("radius"); 
 float vectorLength = r / sin(radian / 2.0);

@P += v@MoveVector;
Conservation of Momentum
User Avatar
Member
4526 posts
Joined: Feb. 2012
Online
Hi,

Have you tried PolyExpand 2d SOP?
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
731 posts
Joined: Dec. 2006
Offline
Also, Orient along curve, to create tangent normals then peak SOP?
Sean Lewkiw
CG Supervisor
Machine FX - Cinesite MTL
User Avatar
Member
44 posts
Joined: April 2017
Offline
Thanks a lot, guys!! I'll try suggested solutions and will get back once I work something out.
  • Quick Links