Sine or Cumulative Point-spacing along Line
2665 6 2- cmbn
- Member
- 15 posts
- Joined: Jan. 2018
- Offline
I have a line with primitive type set to ‘points’. I want to keep the two end-points completely fixed, but redistribute the points in between. I want these to be spaced in a cumulative/sine pattern, so the points in the middle are furthest apart.
Hope someone can help.
Hope someone can help.
Edited by cmbn - Sept. 11, 2018 17:24:56
- Island
- Member
- 340 posts
- Joined: June 2017
- Offline
- cmbn
- Member
- 15 posts
- Joined: Jan. 2018
- Offline
- mestela
- Member
- 1737 posts
- Joined: May 2006
- Online
- Island
- Member
- 340 posts
- Joined: June 2017
- Offline
Since I don't really understand the UV node used above, I'm surmising that mestela is basically using a ramp to drive the y positions. That is more powerful, in that one is not stuck with a sine function. (But I don't know why one would drive vertices to alter point position) However, if you want to use the sine function for this, I would think that you are wanting to create a sine curve and distribute the points evenly along this and then project back onto the y axis. Here is how I would do this:
Edited by Island - Sept. 12, 2018 18:49:16
- Konstantin Magnus
- Member
- 670 posts
- Joined: Sept. 2013
- Offline
Create a normalized length value along each curve with:
Then use one of these functions to stretch it in the middle:
Redistribution could either be done with primuv():
or by pushing it away from the first point towards the last one:
float u = vertexprimindex(0, @vtxnum) / float(primvertexcount(0, @primnum) - 1);
Then use one of these functions to stretch it in the middle:
u = ( sin( fit01(u, -PI * 0.5, PI * 0.5) ) + 1 ) * 0.5; u = (0.33 * pow(u, 3) - 0.5 * pow(u, 2)) * -1 / 0.17; u = smooth(0, 1, u);
Redistribution could either be done with primuv():
v@P = primuv(0, 'P', @primnum, u);
or by pushing it away from the first point towards the last one:
int prim_pts[] = primpoints(0, @primnum); vector pos_start = point(0, 'P', prim_pts[0]); vector pos_end = point(0, 'P', prim_pts[-1]); vector dir = pos_end - pos_start; v@P = pos_start + dir * u;
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- Island
- Member
- 340 posts
- Joined: June 2017
- Offline
-
- Quick Links