# Parabolic Curve

**URL:** https://discourse.processing.org/t/parabolic-curve/31122
**Category:** Coding Questions
**Tags:** homework
**Created:** [July 9, 2021, 1:33am UTC](https://discourse.processing.org/t/parabolic-curve/31122 "2021-07-09T01:33:06Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![bopStu77](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@bopStu77](https://discourse.processing.org/u/bopStu77)
#### Post date: [July 9, 2021, 1:33am UTC](https://discourse.processing.org/t/parabolic-curve/31122/1 "2021-07-09T01:33:07Z")

</div>

I’m new to coding and processing. I have no idea how to begin this code, I wonder how I should start? This what I need to get below.

 ![Screen Shot 2021-07-08 at 9.29.22 PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1fec1c1ac1d576f54f2aa53a40734c3d8ba7a922.jpeg)

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [July 9, 2021, 1:45am UTC](https://discourse.processing.org/t/parabolic-curve/31122/2 "2021-07-09T01:45:29Z")

</div>

There are several ways to approach this …

I can see the same shape repeated again and again – that quarter-circle curve formed from straight lines. If you can get one of these right, you might repeat it (maybe define a function to draw a quarter-circle curve) and rotate & position it using Processing’s transform functions.

\* When you ask a question, try to think of some approach; this is programming, and there are many ways to tackle a problem. Even better, provide a little code you’ve started on.

---

<div class="post-metadata">

### Author: ![bopStu77](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@bopStu77](https://discourse.processing.org/u/bopStu77)
#### Post date: [July 9, 2021, 2:28am UTC](https://discourse.processing.org/t/parabolic-curve/31122/3 "2021-07-09T02:28:45Z")

</div>

Okay Thank you! I’m learning and I’m not aware of all the serval ways. I haven’t started a code but I’ll show you my progress. I’m going to get started!

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 9, 2021, 1:31pm UTC](https://discourse.processing.org/t/parabolic-curve/31122/4 "2021-07-09T13:31:20Z")

</div>

Hello @bopStu77,

There are resources (tutorials, references, examples. etc.) here:  
_[https://processing.org/](https://processing.org/)_

I always think through a problem without even writing a line of code.

I encourage you as a new programmer to make a sincere effort to write your own code with out the influence of someone else’s work or solution.

Glean insight where needed (references, simple examples) and then write your code!

Your efforts will be rewarded in the long run.

To get you started:  
_[Coordinate System and Shapes \ Processing.org](https://processing.org/tutorials/drawing/)_

`:)`

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [July 9, 2021, 2:51pm UTC](https://discourse.processing.org/t/parabolic-curve/31122/5 "2021-07-09T14:51:21Z")

</div>

> [@glv](#):
>
> I always think through a problem without even writing a line of code.

Absolutely the way to go especially in this example because as previously mentioned

> [@tabreturn](#):
>
> that quarter-circle curve formed from straight lines

This image might make it clearer.

 ![Screenshot 2021-07-09 at 15.49.36](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a3da10648601b89e999845a23c62a46d04d8ec2e.png)

So design an algorithm to do this, translate it to code and then you will be well on the way to making the full picture.

---

<div class="post-metadata">

### Author: ![bopStu77](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@bopStu77](https://discourse.processing.org/u/bopStu77)
#### Post date: [July 9, 2021, 5:54pm UTC](https://discourse.processing.org/t/parabolic-curve/31122/6 "2021-07-09T17:54:50Z")

</div>

Hey! So this what I have so far guys, what are the next steps

 ![Screen Shot 2021-07-09 at 1.54.11 PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e1571e9c97a23cdfb1d420c39fac47594e346339.png)

void setup() {  
size(600,600);  
background(255);

}

void draw() {  
stroke (0);  
line(width/2,0,width/2,height);  
line(0,height/2,width,height/2);  
line(width/2,0,280,height/2);  
line(width/2,30,250,height/2);  
line(width/2,50,220,height/2);  
line(width/2,70,190,height/2);  
line(width/2,90,170,height/2);  
line(width/2,110,150,height/2);  
line(width/2,130,130,height/2);  
line(width/2,150,110,height/2);  
line(width/2,170,80,height/2);  
line(width/2,190,50,height/2);  
line(width/2,210,30,height/2);  
line(width/2,230,0,height/2);  
line(width/2,250,0,height/2);  
line(width/2,270,0,height/2);  
}

---

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [July 9, 2021, 6:14pm UTC](https://discourse.processing.org/t/parabolic-curve/31122/7 "2021-07-09T18:14:13Z")

</div>

> [@bopStu77](#):
>
> what are the next steps

When you compare the original sketch to what you see in your current sketch, what can you imagine the the next step would be?

**In other words,** can you write down in a couple of sentences what is happening with the module you’ve created to how it appears in the original sketch?  
The process of doing this will help guide you to the next step…  
🤓

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 9, 2021, 6:46pm UTC](https://discourse.processing.org/t/parabolic-curve/31122/8 "2021-07-09T18:46:18Z")

</div>

Hello,

Please format code properly:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

Look for patterns, sequences and repetition in your code:

```auto
line(width/2, 0, 280, height/2);
line(width/2, 30, 250, height/2);
line(width/2, 50, 220, height/2);
line(width/2, 70, 190, height/2);
line(width/2, 90, 170, height/2);
line(width/2, 110, 150, height/2);
line(width/2, 130, 130, height/2);
line(width/2, 150, 110, height/2);
line(width/2, 170, 80, height/2);
line(width/2, 190, 50, height/2);
line(width/2, 210, 30, height/2);
line(width/2, 230, 0, height/2);
line(width/2, 250, 0, height/2);
line(width/2, 270, 0, height/2);

```

`:)`

---

<div class="post-metadata">

### Author: ![bopStu77](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@bopStu77](https://discourse.processing.org/u/bopStu77)
#### Post date: [July 9, 2021, 8:02pm UTC](https://discourse.processing.org/t/parabolic-curve/31122/9 "2021-07-09T20:02:31Z")

</div>

What I’m wondering is how I can get this sketch’s code to turn around and create that reflection like the sketch above?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 9, 2021, 8:56pm UTC](https://discourse.processing.org/t/parabolic-curve/31122/10 "2021-07-09T20:56:29Z")

</div>

> [@bopStu77](#):
>
> sketch’s code to turn around and create that reflection like the sketch above

when you look at your lines,

- x-from is constant `width/2`, y-from is increasing and
- x-to in decreasing, and y-to is constant `height/2`

repeat for all 4 corners and change for each corner

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [July 10, 2021, 2:37am UTC](https://discourse.processing.org/t/parabolic-curve/31122/11 "2021-07-10T02:37:06Z")

</div>

You can reflect horizontally and vertically using `scale(-1, 1)` and `scale(1, -1)`, respectively. You use the `translate()` function to reposition the drawing space. For example –

```auto
// draw the line at the top left
line(width/2, 0, 0, height/2);

// draw the line at the top right
scale(-1, 1);
translate(-width, 0);
line(width/2, 0, 0, height/2);
resetMatrix();

// draw the line at the bottom right
scale(-1, -1);
translate(-width, -height);
line(width/2, 0, 0, height/2);
resetMatrix();

```

 ![Screenshot from 2021-07-10 14-28-30](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d26bf90d485e401aafaaf5abc803ea8e5260e1b9.png)

Of course, you want to draw many lines to form each curve (not one line), so it’ll help to define a function.
