API:System.Types.TPoint

提供: RAD Studio API Documentation
移動先: 案内検索

Delphi

  TPoint = record
    X: FixedInt;
    Y: FixedInt;
  public
    constructor Create(P : TPoint); overload;
    constructor Create(const X, Y : Integer); overload;
    class operator Equal(const Lhs, Rhs : TPoint) : Boolean;
    class operator NotEqual(const Lhs, Rhs : TPoint): Boolean;
    class operator Add(const Lhs, Rhs : TPoint): TPoint;
    class operator Subtract(const Lhs, Rhs : TPoint): TPoint;
    class operator Implicit(Value: TSmallPoint): TPoint;
    class operator Explicit(Value: TPoint): TSmallPoint;
    class function PointInCircle(const Point, Center: TPoint; const Radius: Integer): Boolean; static; inline;
    class function Zero: TPoint; inline; static;
    function Distance(const P2 : TPoint) : Double;
    procedure SetLocation(const X, Y : Integer); overload;
    procedure SetLocation(const P : TPoint); overload;
    procedure Offset(const DX, DY : Integer); overload;
    procedure Offset(const Point: TPoint); overload;
    function Add(const Point: TPoint): TPoint;
    function Subtract(const Point: TPoint): TPoint;
    function IsZero : Boolean;
    function Angle(const APoint: TPoint): Single;
  end;

C++

struct TPoint: public POINT  {
  TPoint() _ALWAYS_INLINE
  { x = y = 0; }
  TPoint(int _x, int _y) _ALWAYS_INLINE
  { x=_x; y=_y; }
  bool operator ==(const TPoint& pt) const _ALWAYS_INLINE {
    return (x == pt.x) && (y == pt.y);
  }
  bool operator !=(const TPoint& pt) const _ALWAYS_INLINE {
    return !(pt == *this);
  }
  TPoint operator +(const TPoint& rhs) const _ALWAYS_INLINE {
    return TPoint(rhs.x + this->x, rhs.y + this->y);
  }
  TPoint operator -(const TPoint& rhs) const _ALWAYS_INLINE {
    return TPoint(this->x - rhs.x, this->y - rhs.y );
  }
  TPoint& operator +=(const TPoint& rhs) _ALWAYS_INLINE {
    this->x += rhs.x;
    this->y += rhs.y;
    return *this;
  }
  TPoint& operator -=(const TPoint& rhs) _ALWAYS_INLINE {
    this->x -= rhs.x;
    this->y -= rhs.y;
    return *this;
  }
  bool IsZero() const _ALWAYS_INLINE {
    return !x && !y;
  }
  bool IsEmpty() const _ALWAYS_INLINE {
    return IsZero();
  }
  void Offset(int DX, int DY) _ALWAYS_INLINE {
    x += DX;
    y += DY;
  }
  void SetLocation(int nX, int nY) _ALWAYS_INLINE {
    x = nX;
    y = nY;
  }
  void SetLocation(const TPoint& p) _ALWAYS_INLINE {
    x = p.x;
    y = p.y;
  }
  double Distance(const TPoint& p2) const _ALWAYS_INLINE {
    return hypot(static_cast<double>(p2.x - this->x), static_cast<double>(p2.y - this->y));
  }
  static int __fastcall _sqr(int i) _ALWAYS_INLINE { // Helper - private?
     return i*i;
  }
  bool PtInCircle(const TPoint& CircleCenter, int Radius) const _ALWAYS_INLINE {
    return (Radius > 0) && ((_sqr(CircleCenter.x-x)+_sqr(CircleCenter.y-y)) < _sqr(Radius));
  }
  float Angle(const TPoint& P) const _ALWAYS_INLINE {
    return atan2((float)y - P.y,(float)x - P.x);
  }
  __property LONG X = { read=x,   write=x  };
  __property LONG Y = { read=y,   write=y  };
};

プロパティ

種類 可視性 ソース ユニット
record
struct
public
System.Types.pas
SystemTypes.h
System.Types System.Types

説明

このトピックには現在ドキュメントが存在しません。「ノート」を利用してこのトピックの改良について話しあうことができます。