# How to generate points on a line?

**URL:** <https://discourse.processing.org/t/how-to-generate-points-on-a-line/39551>\
**Category:** Coding Questions\
**Created:** [November 2, 2022, 1:50pm UTC](https://discourse.processing.org/t/how-to-generate-points-on-a-line/39551 "2022-11-02T13:50:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Havi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@Havi](https://discourse.processing.org/u/Havi)\
**Post date:** [November 2, 2022, 1:50pm UTC](https://discourse.processing.org/t/how-to-generate-points-on-a-line/39551/1 "2022-11-02T13:50:16Z")

</div>

Hi. I’m trying to make 6 dots along a line(0, random(height), width, random(height)). The dots should be evenly spaced. Can someone please let me know

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [November 2, 2022, 1:59pm UTC](https://discourse.processing.org/t/how-to-generate-points-on-a-line/39551/2 "2022-11-02T13:59:21Z")

</div>

Hello, @Havi, and welcome to Processing Foundation Discourse!

A good way to begin is to first figure out how to do this manually. Draw a line on a piece of paper, with the coordinates of the endpoints represented by variables. How would you then calculate the coordinates of the other points, using the coordinates of the endpoints? After considering that, we can then figure out the code for doing the same.
