# Problem coding Java (TRIANGLE\_FAN )

**URL:** <https://discourse.processing.org/t/problem-coding-java-triangle-fan/26935>\
**Category:** Coding Questions\
**Created:** [January 9, 2021, 10:12pm UTC](https://discourse.processing.org/t/problem-coding-java-triangle-fan/26935 "2021-01-09T22:12:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hom1](https://avatars.discourse-cdn.com/v4/letter/h/dc4da7/32.png) [@hom1](https://discourse.processing.org/u/hom1)\
**Post date:** [January 9, 2021, 10:12pm UTC](https://discourse.processing.org/t/problem-coding-java-triangle-fan/26935/1 "2021-01-09T22:12:07Z")

</div>

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

How to create TRIANGLE\_FAN?

---

<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:** [January 10, 2021, 1:10am UTC](https://discourse.processing.org/t/problem-coding-java-triangle-fan/26935/2 "2021-01-10T01:10:03Z")

</div>

Hello,

- Use P3D
- First vertex is (0, 0, 0)
- Other vertices are about the circumference of a circle with a Z-offset.
- it was easier to work with origin at center of canvas:  
`translate(width/2, height/2);`

You can orient the shape however you wish and change the co-ordinates.

beginShape(POINTS):

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/44cc4f558a795907d1256ebeb736a6eea681bc55.png)

beginShape(TRIANGLE\_FAN):  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/02eab73c6b42d47cba0a29dadaa18eff0f8909fe.png)

```auto
  beginShape(POINTS);
  vertex(0, 0, 0); 
  for(int i = 0; i<=420; i++)
    {
   //generate x and y about the circumference of a circle
    vertex(x, y, 100);    
    }
  endShape();    

```

Be sure to check out all the resources at:  
_[processing.org](http://processing.org)_

`:)`
