亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? douglaspeuckers.pas

?? 簡化線的經典算法倒戈拉斯普克 倒戈拉斯普克
?? PAS
字號:
unit DouglasPeuckers;
{ Implementation of the famous Douglas-Peucker polyline simplification
  algorithm.

  This file contains a 3D floating point implementation, for spatial
  polylines, as well as a 2D integer implementation for use with
  Windows GDI.

  Loosely based on C code from SoftSurfer (www.softsurfer.com)
  http://geometryalgorithms.com/Archive/algorithm_0205/algorithm_0205.htm

  References:
  David Douglas & Thomas Peucker, "Algorithms for the reduction of the number of
  points required to represent a digitized line or its caricature", The Canadian
  Cartographer 10(2), 112-122  (1973)

  Delphi code by Nils Haeck (c) 2003 Simdesign (www.simdesign.nl)
  http://www.simdesign.nl/components/douglaspeucker.html

  ****************************************************************
  The contents of this file are subject to the Mozilla Public
  License Version 1.1 (the "License"); you may not use this file
  except in compliance with the License. You may obtain a copy of
  the License at:
  http://www.mozilla.org/MPL/

  Software distributed under the License is distributed on an
  "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  implied. See the License for the specific language governing
  rights and limitations under the License.
}
interface

uses
  Windows; // We use TPoint from the windows unit

type

  // Generalized float and int types
  TFloat = double;

  // Float point 3D
  TPointFloat3D = packed record
    X: TFloat;
    Y: TFloat;
    Z: TFloat;
  end;

{ PolySimplifyFloat3D:
  Approximates the polyline with 3D float vertices in Orig, with a simplified
  version that will be returned in Simple. The maximum deviation from the
  original line is given in Tol.
  Input:  Tol      = approximation tolerance
          Orig[]   = polyline array of vertex points
  Output: Simple[] = simplified polyline vertices. This array must initially
                     have the same length as Orig
  Return: the number of points in Simple
}
function PolySimplifyFloat3D(Tol: TFloat; const Orig: array of TPointFloat3D;
  var Simple: array of TPointFloat3D): integer;

{ PolySimplifyInt2D:
  Approximates the polyline with 2D integer vertices in Orig, with a simplified
  version that will be returned in Simple. The maximum deviation from the
  original line is given in Tol.
  Input:  Tol      = approximation tolerance
          Orig[]   = polyline array of vertex points
  Output: Simple[] = simplified polyline vertices. This array must initially
                     have the same length as Orig
  Return: the number of points in Simple
}
function PolySimplifyInt2D(Tol: TFloat; const Orig: array of TPoint;
  var Simple: array of TPoint): integer;

implementation

function VecMinFloat3D(const A, B: TPointFloat3D): TPointFloat3D;
// Result = A - B
begin
  Result.X := A.X - B.X;
  Result.Y := A.Y - B.Y;
  Result.Z := A.Z - B.Z;
end;

function DotProdFloat3D(const A, B: TPointFloat3D): TFloat;
// Dotproduct = A * B
begin
  Result := A.X * B.X + A.Y * B.Y + A.Z * B. Z;
end;

function NormSquaredFloat3D(const A: TPointFloat3D): TFloat;
// Square of the norm |A|
begin
  Result := A.X * A.X + A.Y * A.Y + A.Z * A.Z;
end;

function DistSquaredFloat3D(const A, B: TPointFloat3D): TFloat;
// Square of the distance from A to B
begin
  Result := NormSquaredFloat3D(VecMinFloat3D(A, B));
end;

procedure SimplifyFloat3D(var Tol2: TFloat; const Orig: array of TPointFloat3D;
  var Marker: array of boolean; j, k: integer);
// Simplify polyline in OrigList between j and k. Marker[] will be set to True
// for each point that must be included
var
  i, MaxI: integer; // Index at maximum value
  MaxD2: TFloat;    // Maximum value squared
  CU, CW, B: TFloat;
  DV2: TFloat;
  P0, P1, PB, U, W: TPointFloat3D;
begin
  // Is there anything to simplify?
  if k <= j + 1 then exit;

  P0 := Orig[j];
  P1 := Orig[k];
  U  := VecMinFloat3D(P1, P0); // Segment vector
  CU := DotProdFloat3d(U, U); // Segment length squared
  MaxD2 := 0;
  MaxI  := 0;

  // Loop through points and detect the one furthest away
  for i := j + 1 to k - 1 do begin
    W  := VecMinFloat3D(Orig[i], P0);
    CW := DotProdFloat3D(W, U);

    // Distance of point Orig[i] from segment
    if CW <= 0 then begin
      // Before segment
      DV2 := DistSquaredFloat3D(Orig[i], P0)
    end else begin
      if CW > CU then begin
        // Past segment
        DV2 := DistSquaredFloat3D(Orig[i], P1);
      end else begin
        // Fraction of the segment
        try
          B := CW / CU;
        except
          B := 0; // in case CU = 0
        end;
        PB.X := P0.X + B * U.X;
        PB.Y := P0.Y + B * U.Y;
        PB.Z := P0.Z + B * U.Z;
        DV2 := DistSquaredFloat3D(Orig[i], PB);
      end;
    end;

    // test with current max distance squared
    if DV2 > MaxD2 then begin
      // Orig[i] is a new max vertex
      MaxI  := i;
      MaxD2 := DV2;
    end;
  end;

  // If the furthest point is outside tolerance we must split
  if MaxD2 > Tol2 then begin // error is worse than the tolerance

    // split the polyline at the farthest vertex from S
    Marker[MaxI] := True;  // mark Orig[maxi] for the simplified polyline

    // recursively simplify the two subpolylines at Orig[maxi]
    SimplifyFloat3D(Tol2, Orig, Marker, j, MaxI); // polyline Orig[j] to Orig[maxi]
    SimplifyFloat3D(Tol2, Orig, Marker, MaxI, k); // polyline Orig[maxi] to Orig[k]
  end;
end;

function VecMinInt2D(const A, B: TPoint): TPoint;
// Result = A - B
begin
  Result.X := A.X - B.X;
  Result.Y := A.Y - B.Y;
end;

function DotProdInt2D(const A, B: TPoint): TFloat;
// Dotproduct = A * B
begin
  Result := A.X * B.X + A.Y * B.Y;
end;

function NormSquaredInt2D(const A: TPoint): TFloat;
// Square of the norm |A|
begin
  Result := A.X * A.X + A.Y * A.Y;
end;

function DistSquaredInt2D(const A, B: TPoint): TFloat;
// Square of the distance from A to B
begin
  Result := NormSquaredInt2D(VecMinInt2D(A, B));
end;

procedure SimplifyInt2D(var Tol2: TFloat; const Orig: array of TPoint;
  var Marker: array of boolean; j, k: integer);
// Simplify polyline in OrigList between j and k. Marker[] will be set to True
// for each point that must be included
var
  i, MaxI: integer; // Index at maximum value
  MaxD2: TFloat;    // Maximum value squared
  CU, CW, B: TFloat;
  DV2: TFloat;
  P0, P1, PB, U, W: TPoint;
begin
  // Is there anything to simplify?
  if k <= j + 1 then exit;

  P0 := Orig[j];
  P1 := Orig[k];
  U  := VecMinInt2D(P1, P0); // Segment vector
  CU := DotProdInt2D(U, U); // Segment length squared
  MaxD2 := 0;
  MaxI  := 0;

  // Loop through points and detect the one furthest away
  for i := j + 1 to k - 1 do begin
    W  := VecMinInt2D(Orig[i], P0);
    CW := DotProdInt2D(W, U);

    // Distance of point Orig[i] from segment
    if CW <= 0 then begin
      // Before segment
      DV2 := DistSquaredInt2D(Orig[i], P0)
    end else begin
      if CW > CU then begin
        // Past segment
        DV2 := DistSquaredInt2D(Orig[i], P1);
      end else begin
        // Fraction of the segment
        try
          B := CW / CU;
        except
          B := 0; // in case CU = 0
        end;
        PB.X := round(P0.X + B * U.X);
        PB.Y := round(P0.Y + B * U.Y);
        DV2 := DistSquaredInt2D(Orig[i], PB);
      end;
    end;

    // test with current max distance squared
    if DV2 > MaxD2 then begin
      // Orig[i] is a new max vertex
      MaxI  := i;
      MaxD2 := DV2;
    end;
  end;

  // If the furthest point is outside tolerance we must split
  if MaxD2 > Tol2 then begin // error is worse than the tolerance

    // split the polyline at the farthest vertex from S
    Marker[MaxI] := True;  // mark Orig[maxi] for the simplified polyline

    // recursively simplify the two subpolylines at Orig[maxi]
    SimplifyInt2D(Tol2, Orig, Marker, j, MaxI); // polyline Orig[j] to Orig[maxi]
    SimplifyInt2D(Tol2, Orig, Marker, MaxI, k); // polyline Orig[maxi] to Orig[k]

  end;
end;

function PolySimplifyFloat3D(Tol: TFloat; const Orig: array of TPointFloat3D;
  var Simple: array of TPointFloat3D): integer;
var
  i, N: integer;
  Marker: array of boolean;
  Tol2: TFloat;
begin
  Result := 0;
  if length(Orig) < 2 then exit;
  Tol2 := sqr(Tol);

  // Create a marker array
  N := Length(Orig);
  SetLength(Marker, N);
  // Include first and last point
  Marker[0]     := True;
  Marker[N - 1] := True;
  // Exclude intermediate for now
  for i := 1 to N - 2 do
    Marker[i] := False;

  // Simplify
  SimplifyFloat3D(Tol2, Orig, Marker, 0, N - 1);

  // Copy to resulting list
  for i := 0 to N - 1 do begin
    if Marker[i] then begin
      Simple[Result] := Orig[i];
      inc(Result);
    end;
  end;
end;

function PolySimplifyInt2D(Tol: TFloat; const Orig: array of TPoint;
  var Simple: array of TPoint): integer;
var
  i, N: integer;
  Marker: array of boolean;
  Tol2: TFloat;
begin
  Result := 0;
  if length(Orig) < 2 then exit;
  Tol2 := sqr(Tol);

  // Create a marker array
  N := Length(Orig);
  SetLength(Marker, N);
  // Include first and last point
  Marker[0]     := True;
  Marker[N - 1] := True;
  // Exclude intermediate for now
  for i := 1 to N - 2 do
    Marker[i] := False;

  // Simplify
  SimplifyInt2D(Tol2, Orig, Marker, 0, N - 1);

  // Copy to resulting list
  for i := 0 to N - 1 do begin
    if Marker[i]  then begin
      Simple[Result] := Orig[i];
      inc(Result);
    end;
  end;
end;

end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费视频在线观看| 激情欧美一区二区| 免费看黄色91| 91在线观看下载| 26uuu精品一区二区| 亚洲一区在线观看视频| 高清shemale亚洲人妖| 中文字幕精品一区| 韩国三级中文字幕hd久久精品| 色综合天天综合狠狠| 国产亚洲欧美日韩俺去了| 日韩av在线播放中文字幕| 欧美亚洲国产怡红院影院| 国产精品高清亚洲| 国产馆精品极品| 精品国产不卡一区二区三区| 亚洲一区二区黄色| 在线视频一区二区免费| 中文字幕中文字幕在线一区| 国产精品一区三区| 26uuu成人网一区二区三区| 日韩av成人高清| 欧美日韩另类一区| 亚洲电影激情视频网站| 欧美午夜免费电影| 一区二区三区成人在线视频| 91在线视频观看| 亚洲欧洲国产日本综合| 成人av网在线| 综合久久久久久久| 一本色道久久综合亚洲91| 亚洲人吸女人奶水| 色猫猫国产区一区二在线视频| 亚洲色图欧美在线| 亚洲欧洲www| 丁香六月综合激情| 国产精品第四页| av亚洲精华国产精华精华| 欧美国产日韩精品免费观看| 成人黄色av网站在线| 自拍偷拍国产精品| 91久久一区二区| 亚洲第一av色| 欧美电影免费观看高清完整版在线 | 国产亚洲欧美一级| 国产主播一区二区三区| 国产偷国产偷精品高清尤物 | 精品黑人一区二区三区久久| 久久精品理论片| 欧美不卡一区二区三区| 国产成人亚洲综合a∨猫咪| 久久久精品国产免费观看同学| 国产最新精品免费| 亚洲欧洲无码一区二区三区| 色诱亚洲精品久久久久久| 一二三四社区欧美黄| 欧美高清视频一二三区| 韩国女主播一区| 中文字幕一区二区三| 日韩一级视频免费观看在线| 亚洲综合视频网| 欧美日韩激情一区二区三区| 美女看a上一区| 国产精品视频看| 91精品免费在线观看| 国产在线看一区| 亚洲主播在线播放| 久久九九99视频| 欧美日韩视频第一区| 国产精品一区二区黑丝| 亚洲一区在线视频| 久久九九久精品国产免费直播| 在线视频国内一区二区| 九九国产精品视频| 亚洲欧美国产高清| 2014亚洲片线观看视频免费| 91一区二区在线| 国产乱码字幕精品高清av| 亚洲精品菠萝久久久久久久| 欧美大胆一级视频| 色国产精品一区在线观看| 国产乱子伦视频一区二区三区| 亚洲一区二区精品视频| 久久午夜电影网| 日韩三级在线免费观看| 日本二三区不卡| kk眼镜猥琐国模调教系列一区二区 | 日韩久久精品一区| 在线亚洲一区二区| 成人激情午夜影院| 激情图区综合网| 日韩av一区二区三区四区| 一区二区在线观看视频 | 国产精品一区二区久久不卡| 婷婷综合五月天| 亚洲黄一区二区三区| 国产精品美女久久久久高潮| xvideos.蜜桃一区二区| 日韩欧美的一区| 51久久夜色精品国产麻豆| 欧美色综合天天久久综合精品| 成人伦理片在线| 成人免费av资源| 国产999精品久久| 国产精品自产自拍| 国产老肥熟一区二区三区| 久久99精品网久久| 九色综合国产一区二区三区| 首页欧美精品中文字幕| 亚洲制服丝袜一区| 亚洲一区二区三区免费视频| 有坂深雪av一区二区精品| 亚洲色图欧美激情| 亚洲欧美日韩国产综合在线| 中文字幕一区二区三区av| 国产精品乱码久久久久久| 国产精品伦一区二区三级视频| 欧美国产精品v| 国产精品久久久久影院亚瑟| 国产精品午夜在线观看| 国产精品全国免费观看高清| 中文字幕亚洲电影| 日韩毛片精品高清免费| 亚洲免费观看高清完整版在线观看 | 欧美精品电影在线播放| 欧美另类久久久品| 欧美一区日本一区韩国一区| 日韩午夜小视频| 2023国产一二三区日本精品2022| 精品欧美久久久| 中文字幕乱码一区二区免费| 亚洲欧洲在线观看av| 亚洲综合在线视频| 日本午夜精品视频在线观看| 狠狠色丁香久久婷婷综| www.66久久| 欧美日韩成人激情| 精品国产在天天线2019| 国产精品免费看片| 午夜精品久久久| 国产在线播放一区三区四| 日韩精品专区在线影院重磅| 日韩精品在线一区| 中文字幕欧美日韩一区| 亚洲一区二区三区精品在线| 日本视频一区二区三区| 丰满亚洲少妇av| 欧美日韩一区精品| 国产人成一区二区三区影院| 亚洲女女做受ⅹxx高潮| 日本亚洲电影天堂| 99精品欧美一区二区蜜桃免费 | 亚洲3atv精品一区二区三区| 男女男精品网站| 91视频com| 精品久久久三级丝袜| 亚洲狠狠丁香婷婷综合久久久| 久久成人精品无人区| 色婷婷久久久综合中文字幕| 欧美电影免费观看高清完整版在线观看| 国产精品久久午夜| 精品一区二区三区久久| 色欧美88888久久久久久影院| 日韩一区二区免费在线电影| 国产精品久久久99| 久久av中文字幕片| 欧美性做爰猛烈叫床潮| 欧美韩国一区二区| 久久精品国产成人一区二区三区 | 波多野结衣亚洲一区| 欧美一区二区网站| 夜夜精品视频一区二区| 国产成人精品免费一区二区| 制服.丝袜.亚洲.中文.综合| 亚洲少妇30p| 国产精品456露脸| 日韩一区二区三| 午夜久久久影院| 色婷婷久久99综合精品jk白丝| 国产三级精品视频| 久热成人在线视频| 欧美系列在线观看| 综合av第一页| www.欧美精品一二区| 国产日韩欧美精品在线| 精品一区二区三区在线观看| 欧美日韩国产片| 亚洲综合色成人| 色婷婷久久久久swag精品| 国产精品全国免费观看高清| 国产精品自拍在线| www国产成人| 国产精品中文字幕欧美| 日韩欧美一区二区三区在线| 婷婷丁香激情综合| 91精品国产色综合久久ai换脸 | 国产精品一区二区黑丝| 久久综合色8888| 国产精品一线二线三线精华| 欧美tk丨vk视频|