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

• 2

##### Share on other sites

POW! That was it. Thank you very much!

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

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

## Create an account

Register a new account