瀏覽代碼

* Patch from Ondrej Pokorny to implement - and * operators for TPointF

git-svn-id: trunk@32817 -
michael 9 年之前
父節點
當前提交
353f5340dc
共有 1 個文件被更改,包括 25 次插入0 次删除
  1. 25 0
      rtl/objpas/types.pp

+ 25 - 0
rtl/objpas/types.pp

@@ -120,6 +120,10 @@ type
           class operator <> (const apt1, apt2 : TPointF): Boolean;
           class operator + (const apt1, apt2 : TPointF): TPointF;
           class operator - (const apt1, apt2 : TPointF): TPointF;
+          class operator - (const apt1 : TPointF): TPointF;
+          class operator * (const apt1, apt2: TPointF): Single; // scalar product
+          class operator * (const apt1: TPointF; afactor: single): TPointF;
+          class operator * (afactor: single; const apt1: TPointF): TPointF;
        end;
   { TRectF }
 
@@ -600,6 +604,21 @@ begin
   result:=NOT (SameValue(apt1.x,apt2.x) and Samevalue(apt1.y,apt2.y));
 end;
 
+class operator TPointF. * (const apt1, apt2: TPointF): Single;
+begin
+  result:=apt1.x*apt2.x + apt1.y*apt2.y;
+end;
+
+class operator TPointF. * (afactor: single; const apt1: TPointF): TPointF;
+begin
+  result:=apt1.Scale(afactor);
+end;
+
+class operator TPointF. * (const apt1: TPointF; afactor: single): TPointF;
+begin
+  result:=apt1.Scale(afactor);
+end;
+
 class operator TPointF.+ (const apt1, apt2 : TPointF): TPointF;
 begin
   result.x:=apt1.x+apt2.x;
@@ -612,6 +631,12 @@ begin
   result.y:=apt1.y-apt2.y;
 end;
 
+class operator TPointF. - (const apt1: TPointF): TPointF;
+begin
+  Result.x:=-apt1.x;
+  Result.y:=-apt1.y;
+end;
+
 procedure TPointF.SetLocation(const apt :TPointF);
 begin
  x:=apt.x; y:=apt.y;