Problem coding Java (TRIANGLE_FAN )

please format code with </> button * homework policy * asking questions

How to create TRIANGLE_FAN?

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

beginShape(TRIANGLE_FAN):
image

  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

:)

1 Like