掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
座標の求め方 (ID:12601)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
名前にぴったりだったので 即答♪ type XY_Rect = record TopLeft , TopRight , BottomLeft , BottomRight : TPoint; end; // 左上(x1,y1)、左下(x2、y2)、右下(x3,y3)、右上(x4,y4) function SampleRect(X1,Y1,X2,Y2 ,Haba: integer) : XY_Rect; var R : TRect; sin,cos :real; begin Result.TopLeft := Point(X1,Y1); Result.BottomLeft := Point(X2,Y2); sin := (x2-x1) / sqrt(sqr(x1-x2)+sqr(y1-y2)); cos := (y1-y2) / sqrt(sqr(x1-x2)+sqr(y1-y2)); Result.BottomRight.X := trunc(x2+ cos * Haba); Result.BottomRight.Y := trunc(y2+ sin * Haba); Result.TopRight.X := trunc(x1+ cos * Haba); Result.TopRight.Y := trunc(y1+ sin * Haba); // var sin,cos :real; // sin :=(x2-x1) / sqrt(sqr(x1-x2)+sqr(y1-y2)); // cos :=(y2-y1) / sqrt(sqr(x1-x2)+sqr(y1-y2)); // x := x1 + cos * a // y := y1 + sin * a end; // var b : XY_Rect; // b := SampleRect(0,40, 0,0 ,20); // Canvas.Polygon([b.TopLeft,b.BottomLeft,b.BottomRight,b.TopRight]); 三平方の定理 + おまけ 数学/三角関数(SIN、COS、TAN関数) http://homepage1.nifty.com/kenzo30/ex_kisotyu/ex_ks_tyukyu9_7.htm
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.