基于TouchVG和muParser实现了函数图像绘图

本文详细介绍了如何使用TouchVG和muParser在iOS平台上绘制函数图像,包括具体代码实现和示例效果展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用了三天基于TouchVG和muParser实现了iOS上的函数图像绘图,绘图代码(跨平台)如下:

static bool setExpr(MgShape *sp, const char* expr, float mint, float maxt, float step) {
    return ((MgFuncShape*)sp->shape())->setExpr(expr, mint, maxt, step);
}

static void createFuncShapes(MgView *view) {
    MgShape *sp = view->createShapeCtx(MgFuncShape::Type());
    setExpr(sp, "10*t,10*ln(t*t+1)*sin(t)", -6, 6, 0.1f);
    view->shapes()->addShapeDirect(sp);
    
    sp = view->createShapeCtx(MgFuncShape::Type());
    setExpr(sp, "10*t,10*exp(t)-t*sin(t)*cos(t)", -6, 6, 0.1f);
    view->shapes()->addShapeDirect(sp);
    
    view->setCommand("line", "{'points':[-70,0,70,0,0,-40,0,40]}");
}

绘图效果:

func

公式来源

心形图:20*(sqrt(cos(t))*cos(200*t)+sqrt(abs(t))-0.7)*(4-t*t)^0.01,20*t

转载于:https://my.oschina.net/rhcad/blog/318196

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值