Jump to content
LordJashin

TPA Swap? A way to swap all the x's and y's in the TPA

Recommended Posts

Like swapping a TPoints x, and y values. So that now x has y's value, etc. Do that for the whole TPA?

 

For instance:

 

[scar]

program aaa;

 

procedure SwapPoint(var Point1: TPoint);

begin

Point1 := Point(Point1.Y, Point1.X);

end;

 

var

Point1: TPoint;

 

begin

Point1 := Point(3, 5);

WriteLn(PointToStr(Point1));

SwapPoint(Point1);

WriteLn(PointTOStr(Point1));

end.

 

[/scar]

 

I thought there was functions to do this? Or were they removed and why?

 

Maybe I'll post this on the bug tracker...

 

EDIT: Weird MSSL doesn't have it either. This definitely should be added. In math, swapping of x's and y's is very important with somethings...

 

Like this maybe:

 

[scar]

 

function TPASwap(TPA: TPointArray): TPointArray;

var

i: Integer;

begin

Result := CopyTPA(TPA);

for i := 0 to high(Result) do

Result := Point(Result.Y, Result.X);

end;

[/scar]

Edited by LordJashin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...