gpt4 book ai didi

c# - 将屏幕坐标转换为复数坐标

转载 作者:行者123 更新时间:2023-11-28 06:18:05 25 4
gpt4 key购买 nike

有人可以告诉我如何将屏幕坐标转换为复坐标吗?此图显示了有关转换的具体细节

提供您如何在两者之间建立关系的步骤将不胜感激。

谢谢

最佳答案

屏幕 -> 复杂

转换:

screenPointX .. X coordinate on the screen  
screenPointY .. Y coordinate on the screen
screenWidth .. width of the screen
screenHeight .. height of the screen
re .. real component of resulting complex
im .. imaginary component of resulting complex

re = 3 * screenPointX / screenWidth - 2
im = 1 - 2 * screenPointY / screenHeight

C++ 实现示例:

template<class T>
std::complex<T> screenToComplex(
T screenPointX,
T screenPointY,
T screenWidth,
T screenHeight)
{
T re = 3 * screenPointX / screenWidth - 2;
T im = 1 - 2 * screenPointY / screenHeight;
return std::complex<T>(re, im);
}

只需重新排列即可。

关于c# - 将屏幕坐标转换为复数坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29856909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com