Jump to content
bonassus

Line increasing in distance between points with gradient ramp

Recommended Posts

I'm trying to arrange (or add) points on a line so that the distance between them decreases based on a ramp. I have a ramp controlling Cd on the line using:

@ptnum/(@numpt -1)

I tried using a scatter node and generating the points based on Density Attribute Cd. But this results in some randomness in the decreasing distance. 

I thought I could use the resample node's distance attribute. but i haven't figured it out. 

I could one could shed some light here I would appreciate.

Thanks

B

Share this post


Link to post
Share on other sites

Hi bonassus,

create a line with say 50 points and attach a point wrangle, e.g.

@P.y = chramp('shift', @P.y);

or

float shift = chf('shift');
@P.y = pow(@P.y, shift);

and click on the little icon appearing on the right of your code.

line_density.hipnc

  • Like 2

Share this post


Link to post
Share on other sites

Thanks again for your response and to my last question. I'm wondering if you could help me with an other question relating to this set up. If you took the line described above for which the distance between the points decrease. Is there a way to get the distances between each point? Say for use in copying boxes to the points whose heights decrease in proportion to the point distances? Sorry of the convoluted questions. feel free to completely ignore this...

Thanks. 

 

B

Share this post


Link to post
Share on other sites

Hi bonassus, you can access the next point simply by putting @ptnum + 1 in a point function. distance() then does the measuring between the current point @P and the next one pos_next.

vector pos_next = point(0, "P", @ptnum + 1);
f@pscale = distance(@P, pos_next);
removepoint(0, @numpt - 1);

The last point on the line gets removed, because measuring would not work that way and because the stack of boxes would then overshoot the line. Make sure to move the box up by half it´s height, as well.

line_density_copy_boxes.hipnc

Share this post


Link to post
Share on other sites

Hey thanks! that works well. Okay now I have a random question that you may want to answer. 

why do I get a different result if i combine the code from the two wragles in to one? It seems like the order of operation should be the same. No?

 

Thanks Again.

Screenshot from 2017-09-13 10-11-14.png

Share this post


Link to post
Share on other sites

It seems like you disabled the second attribwrangle on the right side. Apart from that you should not paste the code snippets into the same wrangle. Only when all positions are updated in the first wrangle the next one can go through all new positions.

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

×