有人可以告诉我如何将屏幕坐标转换为复坐标吗?此图显示了有关转换的具体细节
提供您如何在两者之间建立关系的步骤将不胜感激。
谢谢
最佳答案
屏幕 -> 复杂
转换:
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/