首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AffineTransform和翻转y轴

AffineTransform和翻转y轴
EN

Stack Overflow用户
提问于 2010-12-21 18:15:43
回答 2查看 2.3K关注 0票数 4

当我试图翻转我创建的坐标系的y轴时,我遇到了一个奇怪的问题:

代码语言:javascript
复制
   private AffineTransform getTransform() {
        if (transform == null) {
            transform = new AffineTransform();
            double scaleX = (double) this.getWidth() / (coordinateSystem.getMaxX() - coordinateSystem.getMinY());
            double scaleY = (double) this.getHeight() / (coordinateSystem.getMaxY() - coordinateSystem.getMinY());
            transform.setToScale(scaleX, scaleY);
            double deltaX = (coordinateSystem.getMaxX() - coordinateSystem.getMinX()) / 2;
            double deltaY = (coordinateSystem.getMaxY() - coordinateSystem.getMinY()) / 2;
            transform.translate(deltaX, deltaY);
        }
        return transform;
    }

AffineTransform设置为缩放和平移。一切正常,除了我的y值是反转的(最大值是坐标系的底部,最小值是顶部)。我尝试通过反转y轴的比例因子来切换这一点。但这并不管用。

我必须让变换按PI旋转,才能实现y轴翻转吗?Y轴的比例因子乘以负1不应该是相同的吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-12-21 19:42:38

你有一个打字错误

代码语言:javascript
复制
double scaleX = (double) this.getWidth() / (coordinateSystem.getMaxX() - coordinateSystem.getMinY());

(最后一个Y应该是X。)也许就是这样。

票数 4
EN

Stack Overflow用户

发布于 2010-12-22 02:41:40

通过PI旋转实际上根本不是一个正确的解决方案,因为它将翻转X轴和Y轴。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4498171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档