# Type mismatch: cannot convert from float to int

**URL:** <https://discourse.processing.org/t/type-mismatch-cannot-convert-from-float-to-int/40434>\
**Category:** Coding Questions\
**Created:** [January 3, 2023, 10:12pm UTC](https://discourse.processing.org/t/type-mismatch-cannot-convert-from-float-to-int/40434 "2023-01-03T22:12:49Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [January 3, 2023, 10:41pm UTC](https://discourse.processing.org/t/type-mismatch-cannot-convert-from-float-to-int/40434/3 "2023-01-03T22:41:01Z")

</div>

Other than point and line, triangle doesn’t know a 3D version as you attempted.

Here is a pyramid though (base with 3 corners):

see : [Find centre of pyramid and rotate from there, not the apex - #3 by Chrisir](https://discourse.processing.org/t/find-centre-of-pyramid-and-rotate-from-there-not-the-apex/40411/3)

**And with a Pyramid class**

- its base with 4 corners (iirc) EDITED
- The position you translate the pyramid to is exactly in the 3D center of the pyramid (like with box and sphere in P3D)

```auto
// Pyramid class

Pyramid pyramid;  

void setup() {
  size(768, 768, P3D);
  pyramid = new Pyramid( 200, height-221, -100 );
}

void draw() {
  background(0);
  lights(); 
  pyramid.display();
}

// ==============================================================================================

class Pyramid {

  float x, y, z; 
  PVector[] basePts = new PVector[4];

  //constr
  Pyramid( float x_, float y_, float z_) {
    x=x_;
    y=y_;
    z=z_;

    for (int i = 0; i < 4; i++ ) {
      float ang = TWO_PI * i / 4;
      basePts[i] = new PVector(
        cos(ang) * 90, 
        90/2.0, 
        sin(ang) * 90 );
      println(basePts[i]);
    } // for
  } // constr

  void display() {
    translate(x, y, z);
    // rotateX(radians(frameCount/8 % 360));
    // rotateY(radians(frameCount/2 % 360));

    fill(255);
    strokeWeight(3);
    stroke(123);

    //sides
    beginShape(TRIANGLES);
    for (int i = 0; i < 4; i++ ) {
      int i2 = (i+1) % 4;
      vertex(basePts[i].x, basePts[i].y, basePts[i].z);
      vertex(basePts[i2].x, basePts[i2].y, basePts[i2].z);
      vertex(0, -90/2.0, 0 );
    }
    endShape();//sides

    // show base
    fill(255, 0, 9); 
    beginShape(); //base
    for (int i = 0; i < 4; i++ ) {
      vertex(basePts[i].x, basePts[i].y, basePts[i].z);
    }
    endShape(CLOSE);
  } //method
  //
} // class
//

```

---

_[View the full topic](https://discourse.processing.org/t/type-mismatch-cannot-convert-from-float-to-int/40434)._
