1
Q
インターセプトは
A
答えて
1
交差点が中央に相対座標(ポイント):
dx = B.X - A.X
dy = B.Y - A.Y
if Width * Abs(dy) < Height * Abs(dx) then
x = Sign(dx) * Width/2
y = dy * x/dx
else
y = Sign(dy) * Height/2
x = dx * y/dy
0
私はJTSトポロジースイート(https://github.com/locationtech/jts)を使用することをお勧めします:私は、オフトピックとして、この質問を閉じるために投票しています
// create a rectangle from center point, width and height
public static LinearRing createRectangle(Coordinate center, double width, double height){
Coordinate upperLeft = new Coordinate(center.x - (width/2), center.y + (height/2));
Coordinate upperRight = new Coordinate(center.x + (width/2), center.y + (height/2));
Coordinate lowerRight = new Coordinate(center.x + (width/2), center.y - (height/2));
Coordinate lowerLeft = new Coordinate(center.x - (width/2), center.y - (height/2));
LinearRing rectangle = new GeometryFactory().createLinearRing(new Coordinate[]{upperLeft, upperRight, lowerRight, lowerLeft, upperLeft});
return rectangle;
}
// calculate intersection
public static Coordinate getIntersectionFromRectangleCenterAndCoordinate(LinearRing rectangle, Coordinate someCoord){
// get your rectangle center coordinate (A)
Coordinate rectangleCenter = rectangle.getCentroid().getCoordinate();
// create line from center to someCoord (A - B)
LineString lineFromCenterToSomeCoord = new GeometryFactory().createLineString(new Coordinate[]{rectangleCenter, someCoord});
// calculate intersection
Geometry intersectionGeom = rectangle.intersection(lineFromCenterToSomeCoord);
// in your case just one intersection point...
Coordinate intersectionCoordinate = intersectionGeom.getCoordinate();
return intersectionCoordinate;
}
関連する問題
- 1. インターセプトAsyncClientHttpRequestFactory
- 2. インターセプト* .aspx
- 3. インターセプトすべてのボタンは
- 4. インターセプトJavascriptをHTMLImageElementは、コンストラクタ
- 5. インターセプトjavascriptコール
- 6. インターセプト要求
- 7. Android AOSPインターセプトKeyEvent.KEYCODE_HOME
- 8. インターセプトjQueryの
- 9. インターセプトfind_by_attributeメソッドアクティブレコード
- 10. slideToggleインターセプトjQueryの()
- 11. IEインターセプトURL
- 12. ヒットテストのインターセプトUIControlEventTouchUpInside:withEvent:
- 13. AppleScriptインターセプト通知
- 14. AndroidのSMSインターセプト
- 15. インターセプトSOAP応答
- 16. JDBC接続のインターセプト
- 17. Unityインターセプト - カスタムインターセプト動作
- 18. インターセプトし、リダイレクトエンティティのSaveChanges
- 19. Unityインターセプトと例外
- 20. nginxプロキシ認証インターセプト
- 21. Flashハッキング/インターセプト/送信
- 22. Bytebuddyインターセプト例外スロー
- 23. タッチイベントのインターセプトとルーティング
- 24. インターセプトelmahロギングASP.NET MVC
- 25. Unity 2.0インターセプトを使用してWCFサービスをインターセプトできない
- 26. インポートまたはインターセプトSMSは、iPhone
- 27. インターセプトURLは春のセキュリティ角度
- 28. Qtクイックqmlイベントをインターセプトするには?
- 29. DBリクエストをインターセプトするには? (MySQL)
- 30. イオンフレームワークでポップアップをインターセプトする方法は?
なぜなら、フレーム化されているので、ジオメトリの問題です。 –
ジオメトリの質問はどこでできますか? –
math.stackexchange.comを試してみましょう。しかし、質問をする前にまずツアーを見てください。 P.S. Javaと関係のない質問には「java」タグを使用しないでください。 – ajb