Author Topic: Polygon Edge XY  (Read 3085 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Polygon Edge XY
« 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;

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Polygon Edge XY
« Reply #1 on: July 21, 2007, 09:15:10 am »
Wait - what is this?!
I don't understand what this does and how it's useful :/
Can't think of anything original to put here...

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Polygon Edge XY
« Reply #2 on: July 21, 2007, 09:24:55 am »
Yeah uh, whats the point... And you should not be posting crap you haven't testing

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: Polygon Edge XY
« Reply #3 on: July 21, 2007, 09:26:19 am »
well, finding how far a polygon is away can be useful... ;Q
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Polygon Edge XY
« Reply #4 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.  :'(
« Last Edit: July 21, 2007, 04:53:50 pm by chrisgbk »

Offline Will

  • Flagrunner
  • ****
  • Posts: 910
Re: Polygon Edge XY
« Reply #5 on: July 21, 2007, 04:04:43 pm »
ummm, mines anyone?

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: Polygon Edge XY
« Reply #6 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...
Can't think of anything original to put here...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Polygon Edge XY
« Reply #7 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 :)