Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- procedure FilterPointsLine2(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer);
- var
- I, Hi, Ind, y, j, LX, LY, OX, OY: Integer;
- P: TPointArray;
- Box: TBox;
- B: Array of Array of Boolean;
- SinAngle,CosAngle : Extended;
- begin
- if Length(Points) < 1 then
- Exit;
- Ind := 0;
- Box:= GetTPABounds(Points);
- SinAngle := sin(Radial);
- CosAngle := -cos(Radial);
- LX := Min(Box.x1, Floor(SinAngle * Radius) + MX);
- LY := Min(Box.y1, Floor(CosAngle * Radius) + MY);
- SetLength(B, max(Box.x2, Ceil(SinAngle * Radius) + MX) + 2 - LX);
- y:= max(Box.x2, Ceil(CosAngle * Radius) + MY) + 2 - LY;
- for I:= 0 to High(B) do
- SetLength(B[I], y);
- Hi:= High(Points);
- for I:= 0 to Hi do
- begin
- B[Points[I].x - LX][Points[I].y - LY]:= True;
- Writeln(Point(Points[I].x - LX, Points[I].y - LY));
- end;
- SetLength(P, Hi + 1);
- OX := MX - LX;
- OY := MY - LY;
- for I:= 0 to Radius do
- begin
- Writeln(Point(Round(SinAngle * I) + OX, Round(CosAngle * I) + OY));
- if(B[Round(SinAngle * I) + OX][Round(CosAngle * I) + OY])then
- begin
- P[Ind].X := Round(SinAngle * I) + MX;
- P[Ind].Y := Round(CosAngle * I) + MY;
- Inc(Ind);
- end;
- end;
- SetLength(P, Ind);
- Points:= P;
- end;
- var
- tpa, clone: TPointArray;
- r: extended;
- i: Integer;
- begin
- tpa := [Point(0, 1), Point(1, 1), Point(1, 0), Point(1, -1), Point(0, -1), Point(-1, -1),
- Point(-1, 0), Point(-1, 1)];
- r := -pi;
- clone := tpa;
- FilterPointsLine2(tpa, r, 10, 0, 0);
- WriteLn(tpa);
- for i := 0 to High(clone) do
- clone[i] := Point(clone[i].x + 100, clone[i].y + 100);
- FilterPointsLine(clone, r, 10, 100, 100);
- for i := 0 to High(clone) do
- clone[i] := Point(clone[i].x - 100, clone[i].y - 100);
- Writeln(clone);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement