简体   繁体   English

你如何旋转多边形?

[英]How do you rotate a polygon?

I'm attempting to rotate a polygon around a fixed axis using the rotate method in Graphics2d. 我正在尝试使用Graphics2d中的rotate方法围绕固定轴旋转多边形。 However, after each rotation, the bounding box coordinates of the polygon don't seem to be updating--only the graphical representation. 但是,每次旋转后,多边形的边界框坐标似乎不会更新 - 只有图形表示。 How might I go about fixing this? 我该怎么办呢?

You are using a library method that simply does a graphical transform. 您正在使用只进行图形转换的库方法。 It is working the way it was designed. 它按照设计的方式工作。 To get the new coordinates, you will have to do the math. 要获得新坐标,您必须进行数学计算。

EDIT: Here's a link to another question that has all the math you need. 编辑:这是一个链接到另一个问题,你需要的所有数学。

Drawing a Rotated Rectangle 绘制旋转矩形

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM