Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on July 20, 2007, 07:37:30 pm

Title: Polygon Edge XY
Post by: DorkeyDear on July 20, 2007, 07:37:30 pm
Script Name: Polygon Edge XY
Script Description: It finds the X and Y coordinates of a point on the edge of a polygon (not completely accurate, you may change the number 10 to a larger number for more accurate numbers) by the intersection of a specified line (made by 2 points) where as point 1 is outside of the polygon and point 2 is within the polygon.
Original Author: Curt (DorkeyDear)
Core Version: 2.6.2 (untested)
Code:
Code: [Select]
procedure GetPolygonEdgeXY(X1,Y1,X2,Y2: single; var X,Y: single; const MaxDist: integer);
var
  i: integer;
  D: single;
begin
  for i := 1 to 10 do begin
    if RayCast(X1,Y1,X2,Y2,D,MaxDist) then begin
      X1 := (X1 + X2) / 2;
      Y1 := (Y1 + Y2) / 2;
    end else begin
      X2 := (X1 + X2) / 2;
      Y2 := (Y1 + Y2) / 2;
    end;
  end;
  X := (X1 + X2) / 2;
  Y := (Y1 + Y2) / 2;
end;
Title: Re: Polygon Edge XY
Post by: zyxstand on July 21, 2007, 09:15:10 am
Wait - what is this?!
I don't understand what this does and how it's useful :/
Title: Re: Polygon Edge XY
Post by: EnEsCe on July 21, 2007, 09:24:55 am
Yeah uh, whats the point... And you should not be posting crap you haven't testing
Title: Re: Polygon Edge XY
Post by: Avarax on July 21, 2007, 09:26:19 am
well, finding how far a polygon is away can be useful... ;Q
Title: Re: Polygon Edge XY
Post by: chrisgbk on July 21, 2007, 03:22:58 pm
A better method would be to convert to parameterized vectors, and calculate the point exactly... I'll find some some VB code I have in a bit, and let someone convert it.

Edit: Scratch that, not possible currently as you can't get map information.  :'(
Title: Re: Polygon Edge XY
Post by: Will on July 21, 2007, 04:04:43 pm
ummm, mines anyone?
Title: Re: Polygon Edge XY
Post by: zyxstand on July 21, 2007, 06:10:53 pm
Yeah uh, whats the point... And you should not be posting crap you haven't testing

but it's curt, he always posts random short-scripts...
Title: Re: Polygon Edge XY
Post by: DorkeyDear on July 23, 2007, 11:28:04 am
:D I love posting random stuff, and its really hard to test a script that is untestable unless somebody with access to the unreleased server version tests it for me :)