System.Types.TSmallPoint
Delphi
TSmallPoint = record
x: SmallInt;
y: SmallInt;
public
[HPPGEN('TSmallPoint(const TSmallPoint& p){ x = p.x; y = p.y; }')]
constructor Create(P : TSmallPoint); overload;
constructor Create(const X, Y : Word); overload;
constructor Create(const X, Y : SmallInt); overload;
class operator Equal(const Lhs, Rhs : TSmallPoint) : Boolean;
class operator NotEqual(const Lhs, Rhs : TSmallPoint): Boolean;
class operator Add(const Lhs, Rhs : TSmallPoint): TSmallPoint;
class operator Subtract(const Lhs, Rhs : TSmallPoint): TSmallPoint;
function Add(const Point: TSmallPoint): TSmallPoint;
function Distance(const P2 : TSmallPoint) : Double;
function IsZero : Boolean;
function Subtract(const Point: TSmallPoint): TSmallPoint;
end;
C++
struct TSmallPoint {
short x;
short y;
static TSmallPoint Create(const short x, const short y) _ALWAYS_INLINE {
TSmallPoint sp;
sp.x = x;
sp.y = y;
return sp;
}
TSmallPoint& init(short ix, short iy) _ALWAYS_INLINE {
x = ix;
y = iy;
return *this;
}
bool operator ==(const TSmallPoint& sp) const _ALWAYS_INLINE {
return x == sp.x && y == sp.y;
}
bool operator !=(const TSmallPoint& sp) const _ALWAYS_INLINE {
return !(*this == sp );
}
TSmallPoint operator +(const TSmallPoint& sp) const _ALWAYS_INLINE {
TSmallPoint res;
return res.init((short)(this->x + sp.x), (short)(this->y + sp.y));
}
TSmallPoint operator -(const TSmallPoint& sp) const _ALWAYS_INLINE {
TSmallPoint res;
return res.init((short)(this->x - sp.x), (short)(this->y - sp.y));
}
TSmallPoint& operator +=(const TSmallPoint& rhs) _ALWAYS_INLINE {
this->x += rhs.x;
this->y += rhs.y;
return *this;
}
TSmallPoint& operator -=(const TSmallPoint& rhs) _ALWAYS_INLINE {
this->x -= rhs.x;
this->y -= rhs.y;
return *this;
}
bool IsZero() const _ALWAYS_INLINE {
return !x && !y;
}
double Distance(const TSmallPoint& p2) const _ALWAYS_INLINE {
return hypot(static_cast<double>(p2.x - this->x), static_cast<double>(p2.y - this->y));
}
};
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
record struct |
public | System.Types.pas SystemTypes.h |
System.Types | System.Types |
説明
TSmallPoint 型は,2 つの 16 ビット座標で点を定義します。
TSmallPoint 型は,各座標を 16 ビット整数で表して点を定義します。x は点の水平座標を指定し,y は点の垂直座標を指定します。