如何顺利地将球体变换为半球体

发布于 2024-09-26 06:44:56 字数 671 浏览 3 评论 0原文

我正在使用第 3 方“旋转器”对象,它沿着球体表面提供平滑、随机的旋转。旋转器用于控制相机(请参阅xscreensaver源代码中的rotator.h/c)。

旋转器的输出是纬度和经度。 我想要的是让相机保持在“赤道”上方 - 因此仅限于半球。

我宁愿不修改旋转器本身。所以我可以获取纬度输出并使用它的绝对值。然而,穿过赤道的平滑旋转运动不会产生平滑的相机运动:它会反弹。

我想我可以将旋转器的输出纬度从其当前范围缩放到我的目标范围:例如 f(lat) = (lat+1)/2 会将 (0, 1) 范围映射到 (0.5, 1)。即把整个“地球”映射到北半球。动作还是会很顺利。但旋转器原本的“南极”将成为我相机的“赤道”。这不会导致奇怪的运动吗?也许有不连续性?我不知道。

是否有另一种方法可以将球体(纬度和经度)平滑地映射到半球?

更新:

感谢您的关注和回复。有几个人要求对“平滑”进行澄清。我的意思是不生涩:旋转器速度的微小变化应该映射到相机速度的微小变化。如果我只取纬度的绝对值,则旋转器穿过赤道时速度的零变化将转化为相机速度的突然符号翻转(也称为弹跳)。

IIRC 这相当于要求速度的一阶导数是连续的。连续二阶导数可能很好,但我认为它不是必需的。

I am using a 3rd-party "rotator" object, which is providing a smooth, random rotation along the surface of a sphere. The rotator is used to control a camera (see rotator.h/c in source code for xscreensaver).

The output of the rotator is latitude and longitude.
What I want is for the camera to stay above the "equator" - thus limited to a hemisphere.

I'd rather not modify the rotator itself. So I could take the latitude output and use the absolute value of it. However, smooth rotator movement across the equator would not produce smooth camera motion: it would bounce.

I suppose I could scale output latitude from the rotator from its current range to my target range: e.g. f(lat) = (lat+1)/2 would map the (0, 1) range to (0.5, 1). I.e. map the whole "globe" to the northern hemisphere. The movement would still be smooth. But what would be intended as the "south pole" by the rotator would become the "equator" for my camera. Wouldn't that result in strange motion? Maybe discontinuities? I'm not sure.

Is there another way to map a sphere (latitude and longitude) to a hemisphere, smoothly?

Update:

Thanks for your attention and responses. A couple of people have asked for clarification on "smooth". I mean not jerky: a small change in velocity of the rotator should be mapped to a small change in velocity of the camera. If I just took the absolute value of the latitude, a zero change in velocity of the rotator as it crossed the equator would translate to an abrupt sign-flip of the velocity of the camera (a.k.a. a bounce).

IIRC this is equivalent to requiring that the first derivative of the velocity be continuous. Continuous second derivative might be nice but I don't think it's essential.

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

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

发布评论

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

评论(4

半夏半凉 2024-10-03 06:44:56

速度是位置的导数。通过“镜像”纬度值,您可以在到达赤道时在位置函数中创建一个“角”。因此,为了获得平滑过渡,需要将线性位置(即纬度作为时间的函数)映射到在赤道附近缓慢变化的函数,并且在赤道处一阶导数为 0。

tom10 对于映射 lat'(lat) = (lat)^2 的建议就是此类函数的一个很好的示例。但是,您需要对结果进行标准化,以便得到lat'(90deg) = 90deg。因此,正确的映射应该是:

lat'(lat) = 90*(lat/90)^2

抛物线的替代方法是 sin() 函数,其中适当的转移和标准化。根据您希望“远离”赤道时的速度与原始速度的接近程度,您可以具有更高或更低阶的指数值,例如:

lat'(lat) = 90*( |lat| / 90)^K

The velocity is the derivative of the position. By just "mirroring" the lat value, you create a "corner" in the position function when hitting the equator. So, in order to get a smooth transition, you need to map the linear position (i.e, the latitude as a function of the time) to a function that changes slowly near the equator, and where the 1st derivative is 0 at the equator.

tom10's suggestion for mapping lat'(lat) = (lat)^2 is a good example of such a function. However, you need to normalize the result so you get lat'(90deg) = 90deg. So, the correct mapping should be:

lat'(lat) = 90*(lat/90)^2

An alternative to a parabole is a sin() function, with the appropriate shifting and normalizing. Depending on how much you want the velocity to be close to the original velocity when "away" from the equator, you can have higher or lower order exponent values, like:

lat'(lat) = 90*( |lat| / 90)^K

香草可樂 2024-10-03 06:44:56

球体和半球在拓扑上不同,因此无法以满足您的标准的方式在两者之间平滑映射。

A sphere and a hemisphere are topologically different, therefore there is no way to smoothly map between the two in a manner that would satisfy your criteria.

听不够的曲调 2024-10-03 06:44:56

您可以做一些平滑的事情,而不是纬度的绝对值,例如 (latitiude)2

Instead of the absolute value of the latitude you could do something smooth, like (latitiude)2.

感情旳空白 2024-10-03 06:44:56

我不完全确定我理解你的问题,所以我会重新陈述以防万一:

您希望能够转换任何点(由纬度和经度给出)并将其转换为半球上的点,以便“运动平滑”(即球体上的小运动转换为球体上的小运动)半球)

)在这种情况下,我相信您可以简单地“将球体向后折叠”(例如,取赤道纬度的模)。

I'm not entirely certain I understand your question, so I'll re-state it just in case:

You want to be able to convert any point (given by latitude and longitude) and convert that to a point on a hemisphere so that "movement is smooth" (i.e. a small movement on the sphere translates to a small movement on the hemisphere)

In this case I believe that you can simply "fold the sphere in back on itself" (e.g. take the Modulo of the latitude about the equator).

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