Einzelnen Beitrag anzeigen

mdadali

Registriert seit: 10. Feb 2003
Ort: Linz
7 Beiträge
 
Delphi 10.4 Sydney
 
#1

C++ Code übersetzen

  Alt 8. Nov 2022, 13:03
Delphi-Version: 10.4 Sydney
Hallo,

Ich würde gerne folgende C++ Funktion ins Delphi (Objekt Pascal) übersetzen.
Ich hoffe jemand kann mir helfen.
Danke.

C++ Makros ?
Delphi-Quellcode:
#define GE_PI 3.14159265358979323846 // 180
#define GE_PI2 (GE_PI / 2.0) // 1,57079632679489661923 90
#define GE_PI4 (GE_PI / 4.0) // 0,785398163397448309615 45
#define GE_2PI (GE_PI+GE_PI) // 6,28318530717958647692 360
C++ Funktion:
Delphi-Quellcode:
//-----------------------------------------------
// Angle from point 0,0 to this point (0..2PI)
//-----------------------------------------------
double CGePoint::Angle () const
{
  if (x == 0.0) {
    if (y == 0.0){
      return 0.0;
    }

    return (y>0.0)? GE_PI2 : GE_DEG270;
  }else{
    if (y == 0.0){
      return (x>0.0)? 0.0 : GE_PI;
    }

    if (x > 0.0){
      if (y > 0.0){
        return atan( y / x );
      }
else{
        return atan( y / x ) + GE_2PI;
      }

    }else{
      return atan( y / x ) + GE_PI;
    }

  }
}
Mustafa
  Mit Zitat antworten Zitat