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

标签 c# c++ fractals mandelbrot

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

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

谢谢

最佳答案

屏幕 -> 复杂

转换:

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/

相关文章:

c++ - 自定义错误函数 C++

c# - 解析 2 位日期

c# - 如何在 ASP.Net Core 2 中返回 CSV 文件?

c++ - 为什么 C++ 允许对派生类方法进行更严格的访问?

c++ - 类成员声明的快捷方式

javascript - 简单的 JS/html5 分形树,线宽递减

c - 带有 pthread 的 Buddhabrot 分形

java - 如何制作金色分形树

c# - MVC 4 具有不同 View 文件夹的相同逻辑

c# - Task.Run 和 UI 进度更新