Author Topic: Pseudosphere  (Read 2713 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7504
  • AKA Daniel
Pseudosphere
« on: January 01, 2010, 09:38:36 AM »
 8-)

Code: [Select]
static void drawPoints(const AcGePoint3dArray &pts, short color)
  {
    AcDbDatabase *pDatabase = acdbHostApplicationServices()->workingDatabase();
    AcDbBlockTableRecordPointer pBlockTableRecord(pDatabase->currentSpaceId(),AcDb::kForWrite);
    for(size_t i=0 ; i<pts.length();i++)
    {
      AcDbPoint *pPoint = new AcDbPoint(pts[i]);
      pPoint->setColorIndex(color);
      if(pBlockTableRecord->appendAcDbEntity(pPoint) != eOk)
        delete pPoint;
      else
        pPoint->close();
    }
  }


  //Pseudosphere
  //By Roger Bagula
  //C source by Paul Bourke
  //http://local.wasp.uwa.edu.au/~pbourke/geometry/pseudosphere/
  static void BrxVsArx_doit(void)
  {
    int i,j;
    int n = 250;
    double theta1,theta2;
    double phi1,phi2;
    double x,y,z;
    AcGePoint3dArray pts;

    for (i=0;i<n;i++) {
      theta1 = -PI + TWOPI * i / (double)n;
      theta2 = -PI + TWOPI * (i+1) / (double)n;

      for (j=0;j<2*n;j++) {
        phi1 = -TWOPI + 2 * TWOPI * j / (2.0*n);
        phi2 = -TWOPI + 2 * TWOPI * (j+1) / (2.0*n);

        x = phi1-tanh(phi1);
        y = sech(phi1)*sin(theta1);
        z = sech(phi1)*cos(theta1);
        pts.append(AcGePoint3d(x,y,z));
        x = phi1-tanh(phi1);
        y = sech(phi1)*sin(theta2);
        z = sech(phi1)*cos(theta2);
        pts.append(AcGePoint3d(x,y,z));
        x = phi2-tanh(phi2);
        y = sech(phi2)*sin(theta2);
        z = sech(phi2)*cos(theta2);
        pts.append(AcGePoint3d(x,y,z));
        x = phi2-tanh(phi2);
        y = sech(phi2)*sin(theta1);
        z = sech(phi2)*cos(theta1);
        pts.append(AcGePoint3d(x,y,z));
      }
    }
    drawPoints(pts,1);
    pts.removeAll();
    for (i=0;i<n;i++) {
      theta1 = -PI + TWOPI * i / (double)n;
      theta2 = -PI + TWOPI * (i+1) / (double)n;
      for (j=0;j<2*n;j++) {
        phi1 = -TWOPI + 2 * TWOPI * j / (2.0*n);
        phi2 = -TWOPI + 2 * TWOPI * (j+1) / (2.0*n);
        x = (phi1 - tanh(phi1)) / (phi1*phi1 - 2 * tanh(phi1) + 1);
        y = -sech(phi1) * sin(theta1) / (phi1*phi1 - 2 * tanh(phi1) + 1);
        z = -sech(phi1) * cos(theta1) / (phi1*phi1 - 2 * tanh(phi1) + 1);
        pts.append(AcGePoint3d(x,y,z));
        x = (phi1 - tanh(phi1)) / (phi1*phi1 - 2 * tanh(phi1) + 1);
        y = -sech(phi1) * sin(theta2) / (phi1*phi1 - 2 * tanh(phi1) + 1);
        z = -sech(phi1) * cos(theta2) / (phi1*phi1 - 2 * tanh(phi1) + 1);
        pts.append(AcGePoint3d(x,y,z));
        x = (phi2 - tanh(phi2)) / (phi2*phi2 - 2 * tanh(phi2) + 1);
        y = -sech(phi2) * sin(theta2) / (phi2*phi2 - 2 * tanh(phi2) + 1);
        z = -sech(phi2) * cos(theta2) / (phi2*phi2 - 2 * tanh(phi2) + 1);
        pts.append(AcGePoint3d(x,y,z));
        x = (phi2 - tanh(phi2)) / (phi2*phi2 - 2 * tanh(phi2) + 1);
        y = -sech(phi2) * sin(theta1) / (phi2*phi2 - 2 * tanh(phi2) + 1);
        z = -sech(phi2) * cos(theta1) / (phi2*phi2 - 2 * tanh(phi2) + 1);
        pts.append(AcGePoint3d(x,y,z));
      }
    }
    drawPoints(pts,5);
  }

  inline double static sech(double d)
  {
    return(1.0 / cosh(d));
  }

Retired

web.pawan

  • Guest
Re: Pseudosphere
« Reply #1 on: January 01, 2010, 09:58:43 AM »
[offtopic] wow! looks good. can be used to show simulation of black holes, supernova's with some animation  :-)

frtfff

  • Bull Frog
  • Posts: 236
Re: Pseudosphere
« Reply #2 on: January 02, 2010, 10:10:32 PM »
 :kewl:

SEANT

  • Bull Frog
  • Posts: 344
Re: Pseudosphere
« Reply #3 on: January 03, 2010, 06:11:05 AM »
That definitely does have some extra-dimensional quality about it. :-o
Sean Tessier
AutoCAD 2016 Mechanical

frtfff

  • Bull Frog
  • Posts: 236
Re: Pseudosphere
« Reply #4 on: January 07, 2010, 09:22:10 PM »
 :kewl: