如何在 2D opengl es 场景中获得绝对平移

发布于 2024-12-26 06:42:51 字数 154 浏览 4 评论 0原文

我有一个在 2d opengl es 1.1 中渲染的可平移/可缩放图像。缩放后,如何获得从图像左侧到可视区域左侧的绝对位置? 这是一张图片来澄清我的意思:

在此处输入图像描述

I have a pannable/zoomable image rendered in a 2d opengl es 1.1. After zooming, how can i get the absolute position from the left side of the image to the left side of my viewable area?
Heres an image to clarify what i mean:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

避讳 2025-01-02 06:42:51

好吧,我对 IOS 了解不多,但从逻辑上讲,根据原点在哪里以及图像如何绘制到屏幕上,您可以计算距图像 x 位置的距离。例如,如果您的原点位于屏幕的左上角 (0,0),并且您的图像是从左上角绘制的(例如 (-10, 0)),那么您的距离将只是绝对值图像的 x 位置(例如 10 个单位)。但是,如果您的原点位于中心,那么您必须考虑屏幕尺寸并减去宽度的一半来获得距离。这可能听起来令人困惑,但它应该只是基本的数学。

Well I don't know much about IOS, but logically speaking, depending on where the origin is and how your image is being drawn onto the screen, you could just calculate the distance from the x position of the image. For instance, if your origin is on the top left of the screen (0,0), and your image is being drawn from the top left (eg. (-10, 0)), then your distance would simply be the absolute value of the x position of your image (eg. 10 units). However, if your origin was lets say, at the center, then you would have to take the screen size into account and subtract half of the width to achieve the distance. It may sound confusing but it should just be basic math.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文