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.
How to expand/shrink curve?
2195 4 0- assignators
- Member
- 44 posts
- Joined: April 2017
- Offline
- cncverkstad
- Member
- 122 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
- animatrix_
- Member
- 4533 posts
- Joined: Feb. 2012
- Offline
Hi,
Have you tried PolyExpand 2d SOP?
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
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- mrCatfish
- Member
- 731 posts
- Joined: Dec. 2006
- Offline
- assignators
- Member
- 44 posts
- Joined: April 2017
- Offline
-
- Quick Links