Skip to content
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
CFD中文网

CFD中文网

  1. CFD中文网
  2. CFD彩虹条
  3. 如何在把下面这个东西画成图

如何在把下面这个东西画成图

已定时 已固定 已锁定 已移动 CFD彩虹条
8 帖子 3 发布者 4.4k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    写于 最后由 编辑
    #1

    下面这些星号,我有每个星号的位置信息,比如(0.1 0.1), (0.1 0.124),这些可以当做位置坐标。我还有每个位置坐标上面的压力值,比如5, 6。怎么在C++环境下,最简单的把这个云图画出来?gnuplot是不是可以?

    最简单的,有位置信息:

    (0.1 0.1)
    (0.1 0.124)
    

    压力值:

    4
    5
    

    怎么能画出类似CFD那种云图呢?

    微信图片_20240711164803.jpg

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • 星 离线
    星 离线
    星星星星晴
    写于 最后由 编辑
    #2

    问GPT啊

    游荡

    1 条回复 最后回复
  • 星 离线
    星 离线
    星星星星晴
    写于 最后由 编辑
    #3

    GPT说:
    在C++环境下,你可以使用一些图形库来绘制这个云图,比如OpenGL或者SFML。以下是一个简单的示例代码,使用SFML库来绘制一个简单的云图:

    #include <SFML/Graphics.hpp>
    #include <vector>
    int main()
    {
        // 创建窗口
        sf::RenderWindow window(sf::VideoMode(800, 600), "Cloud Map");
        // 创建星号位置信息和压力值
        std::vector<sf::Vector2f> positions = {sf::Vector2f(100, 100), sf::Vector2f(200, 200), sf::Vector2f(300, 300)};
        std::vector<int> pressures = {5, 6, 7};
        // 创建圆形表示星号
        std::vector<sf::CircleShape> circles;
        for (int i = 0; i < positions.size(); i++)
        {
            sf::CircleShape circle(5);
            circle.setPosition(positions[i]);
            circles.push_back(circle);
        }
        // 主循环
        while (window.isOpen())
        {
            // 处理事件
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
            }
            // 清空窗口
            window.clear();
            // 绘制圆形
            for (int i = 0; i < circles.size(); i++)
            {
                circles[i].setFillColor(sf::Color(255, 255, 255, pressures[i] * 25)); // 根据压力值设置颜色的透明度
                window.draw(circles[i]);
            }
            // 显示窗口内容
            window.display();
        }
        return 0;
    }
    

    除了使用OpenGL、SFML和gnuplot之外,还有其他方法可以绘制云图,比如使用OpenCV库。以下是一个简单的示例代码,使用OpenCV库来绘制一个简单的云图:

    #include <opencv2/opencv.hpp>
    #include <vector>
    int main()
    {
        // 创建一个空白图像
        cv::Mat cloudMap = cv::Mat::zeros(600, 800, CV_8UC3);
        // 创建星号位置信息和压力值
        std::vector<cv::Point> positions = {cv::Point(100, 100), cv::Point(200, 200), cv::Point(300, 300)};
        std::vector<int> pressures = {5, 6, 7};
        // 在图像上绘制星号
        for (int i = 0; i < positions.size(); i++)
        {
            cv::circle(cloudMap, positions[i], 5, cv::Scalar(255, 255, 255), -1);
        }
        // 显示图像
        cv::imshow("Cloud Map", cloudMap);
        cv::waitKey(0);
        return 0;
    }
    

    游荡

    1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    写于 最后由 编辑
    #4

    就是那些都得调用库,想找个简单点的..

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • bestucanB 离线
    bestucanB 离线
    bestucan 版主 大神
    写于 最后由 编辑
    #5

    pointValue.txt :

    # x y z
    0.1 0.1 4
    0.1 0.124 5
    0.2 0.4 2
    0.3 0.5 4.5
    

    pointValue.gplt :

    set terminal pdfcairo enhanced color size 15cm,10cm font 'Verdana, 10'
    #set terminal pngcairo size 800,600 enhanced font 'Verdana,10'
    
    # Set output file
    set output 'pointValue.pdf'
    
    # Set title and labels
    set title 'Plot with Point Coordinates and Values'
    set xlabel 'X-axis'
    set ylabel 'Y-axis'
    set zlabel 'Z-axis'
    
    # Set grid
    set grid
    
    # Set data style
    set style data points
    
    # Load the data file and plot it
    plot 'pointValue.txt' using 1:2:3 with points pointtype 7 pointsize 1.5 palette
    
    

    pointValue.pdf :
    pointValue.jpg

    这可以改颜色: http://gnuplot.info/demo/pm3dcolors.html

    滚来滚去……~(~o ̄▽ ̄)~o 滚来滚去都不能让大家看出来我不是老师么 O_o

    异步沟通方式(《posting style》from wiki)(下载后打开):
    https://www.jianguoyun.com/p/Dc52X2sQsLv2BRiqnKYD
    提问的智慧(github在gitee的镜像):
    https://gitee.com/bestucan/How-To-Ask-Questions-The-Smart-Way

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 bestucan 最后由 编辑
    #6

    屌! 我试试

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    写于 最后由 编辑
    #7

    流弊!

    pinncavity.png

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    bestucanB 1 条回复 最后回复
  • bestucanB 离线
    bestucanB 离线
    bestucan 版主 大神
    在 中回复了 李东岳 最后由 编辑
    #8

    @李东岳 :140: ,效果很好。还能把点调大点,调成正方形,然后就可以没有空隙了。pointtype, pointsize这些

    滚来滚去……~(~o ̄▽ ̄)~o 滚来滚去都不能让大家看出来我不是老师么 O_o

    异步沟通方式(《posting style》from wiki)(下载后打开):
    https://www.jianguoyun.com/p/Dc52X2sQsLv2BRiqnKYD
    提问的智慧(github在gitee的镜像):
    https://gitee.com/bestucan/How-To-Ask-Questions-The-Smart-Way

    1 条回复 最后回复

  • 登录

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]