搜索
您的当前位置:首页正文

Android模拟绘制极坐标方程

来源:二三娱乐

零、前言

引入
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

implementation 'com.github.toly1994328:logic-canvas-android:0.05'


一、看下几个效果:

极坐标绘图2.png 极坐标绘图1.png 极坐标绘图.png

二、绘制代码:

    //ρ= a(1-cosθ)
    //ρ= a(1-sin3θ)
    //ρ=(e^(cosθ)- 2cos(4θ) + [sin(θ/12)]^5)*100
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Painter painter = PainterEnum.INSTANCE.getInstance(canvas);
        CanvasUtils.drawCoord(getContext(), coo, 50, canvas);
        CanvasUtils.drawGrid(getContext(), 50, canvas);
        
        for (int i = 1; i < 500; i++) {
            float ang = (float) (i);
            float rad = Logic.rad(ang);

            float c = (float) (100 * (1 - Math.sin(rad)));
//          float c = (float) (100 * (1 - Math.cos(3*Logic.rad(ang))));
//          float c = (float) (Math.pow(Math.E,Math.cos(rad)) - 2 * Math.cos(4 * rad) + Math.pow(Math.sin(rad / 12), 5));
            painter.draw(new ShapeDot()
                    .ang(ang).c(c).b(4).coo(coo)
                    .fs(Color.parseColor("#F05617")));
        }
    }

就酱紫


后记、

1.声明:

[1]本文由张风捷特烈原创,转载请注明
[2]欢迎广大编程爱好者共同交流
[3]个人能力有限,如有不正之处欢迎大家批评指证,必定虚心改正
[4]你的喜欢与支持将是我最大的动力

2.连接传送门:
3.联系我
4.欢迎关注我的微信公众号,最新精彩文章,及时送达:
公众号.jpg
Top