Fx_

函数绘制测试

Stars
6

Fx

45,``

5)()


1.1
A,Bf,  
Ax,Bf(x)
"f:AB"AB
y=f(x),xA

xx[]
xy{f(x)|xA}[]

2.
D R,f:DRD
y=f(x),x D

xyDDf,Df=D.
Rf=f(D)={y|y=f(x),x D}

3.
X,YfXx,
f,YyfXY
f:XY

yx(f)f(x),y=f(x)
xy(f)

1px x DfSet f(x) Mapxy


0.

View

public class MathView extends View {
    private Point mCoo = new Point(500, 700);//
    private Picture mCooPicture;//canvas
    private Picture mGridPicture;//canvas
    private Paint mHelpPint;//
    private Paint mPaint;//
    private Path mPath;//
    public MathView(Context context) {
        this(context, null);
    }

    public MathView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();//
    }

    private void init() {
        //
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(Color.BLUE);
        mPaint.setStrokeWidth(2);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        //
        mPath = new Path();

        //
        mHelpPint = HelpDraw.getHelpPint(Color.RED);
        mCooPicture = HelpDraw.getCoo(getContext(), mCoo);
        mGridPicture = HelpDraw.getGrid(getContext());
    }
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        HelpDraw.draw(canvas, mGridPicture, mCooPicture);
        canvas.save();
        canvas.translate(mCoo.x, mCoo.y);
        canvas.scale(1, -1);//y
        canvas.restore();
    }

AndroidCanvas,


1.y=x,[-200,300]

1.1
private TreeSet<Float> Df = new TreeSet<>();//
private Map<Float, Float> funMap = new HashMap<>();//
private Paint mTextPaint;//

1.2:
/**
 * 
 */
private void initDf() {
    for (float i = -200; i <= 300; i++) {
        Df.add(i);//
    }
}

1.3fx
/**
 * 
 * @param x ()
 * @return ()
 */
private float f(Float x) {
    float y = x;
    return y;
}

1.4:,xf(x)
/**
 * ,xf(x)
 */
private void map() {
    Df.forEach(x -> {
        funMap.put(x, f(x));
    });
    //
}

1.5:
/**
 * 
 * @param canvas 
 * @param map 
 */
private void drawMap(Canvas canvas, Map<Float, Float> map) {
    map.forEach((k, v) -> {
        canvas.drawPoint(k, v, mPaint);
    });
}

2.y=|x|,[-200,300]
/**
 * 
 * @param x ()
 * @return ()
 */
private float f(Float x) {
    float y=Math.abs(x);
    return y;
}

3.,[-200,300]
/**
 * 
 * @param x ()
 * @return ()
 */
private float f(Float x) {
    float y=(x - 100) * (x - 100) / 200 + 100;
    return y;
}

4.log10(x),[1,1000]
/**
 * 
 */
private void initDf() {
    for (float i = 1; i <= 1000; i++) {
        Df.add(i);//
    }
}

/**
 * 
 *
 * @param x ()
 * @return ()
 */
private float f(Float x) {
    float y = (float) (100.f * Math.log10(x));
    return y;
}

5.[-400,500]
/**
 * 
 */
private void initDf() {
    for (float i = -400; i <= 500; i++) {
        Df.add(i);//
    }
}

/**
 * 
 *
 * @param x ()
 * @return ()
 */
private float f(Float x) {
    float y= 100*(float) Math.pow(Math.E,x/300f);
    return y;
}

6.[-360,450]
/**
 * 
 */
private void initDf() {
    for (float i =-360; i <= 450; i++) {
        Df.add(i);//
    }
}

/**
 * 
 *
 * @param x ()
 * @return ()
 */
private float f(Float x) {
    float y= (float) (100*Math.sin(Math.PI/180*x));
    return y;
}

1).thtap 2).


1.= 100*(1-cos)
/**
 * 
 */
private void initDf() {
    for (float i = 1; i <= 360; i++) {
        Df.add(i);//
    }
}

/**
 * 
 *
 * @param canvas 
 * @param map    
 */
private void drawMap(Canvas canvas, Map<Float, Float> map) {
    map.forEach((thta, p) -> {
        Log.e(TAG, "drawMap: "+p+thta);
        canvas.drawPoint((float) (p * Math.cos(thta)), (float) (p * Math.sin(thta)), mPaint);
    });
}

/**
 * 
 *
 * @param thta ()
 * @return ()
 */
private float f(Float thta) {
    float p = (float) (100 * (1 - Math.cos(thta)));
    return p;
}

/**
 * ,xf(x)
 */
private void map() {
    Df.forEach(x -> {
        float thta = (float) (Math.PI / 180 * x);
        funMap.put(thta, f(thta));
    });
    //
}

2.= 100*(1-4*sin)
/**
 * 
 *
 * @param thta ()
 * @return ()
 */
private float f(Float thta) {
    float p = (float) (100 * (1 - Math.sin(4 * thta)));
    return p;
}

3.=(e^(cos)- 2cos(4) + [sin(/12)]^5)*100
/**
 * 
 *
 * @param thta ()
 * @return ()
 */
private float f(Float thta) {
    float p = (float) (100f*(Math.pow(Math.E,Math.cos(thta)) - 2 * Math.cos(4 * thta) + Math.pow(Math.sin(thta / 12), 5)));;
    return p;
}

4.= a*
/**
 * 
 *
 * @param thta ()
 * @return ()
 */
private float f(Float thta) {
    float p = 30*thta;
    return p;
}

5.
/**
 * 
 *
 * @param thta ()
 * @return ()
 */
private float f(Float thta) {
    float p = 200;
    return p;
}


1.x=a/cos,y=btan
    /**
     * 
     */
    private void initDf() {
        for (float i = 0; i <= 360 ; i++) {
            Df.add(i);//
        }
    }

    /**
     * 
     *
     * @param canvas 
     * @param map    
     */
    private void drawMap(Canvas canvas, Map<Float, Float> map) {
        map.forEach((k, v) -> {
            canvas.drawPoint(k, v, mPaint);
        });
    }

    /**
     * 
     *
     * @param thta ()
     * @return y()
     */
    private float y(Float thta) {
        float y = (float) (100 * Math.tan(thta));
        return y;
    }

    /**
     * 
     *
     * @param thta ()
     * @return x()
     */
    private float x(Float thta) {
        float x = (float) (200 / Math.cos(thta));
        return x;
    }

    /**
     * ,xf(x)
     */
    private void map() {
        Df.forEach(x -> {
            float thta = (float) (Math.PI / 180 * x);
            funMap.put(x(thta), y(thta));
        });
        //
    }

2.x=a*cos,y=bsin
/**
 * 
 *
 * @param thta ()
 * @return y()
 */
private float y(Float thta) {
    float y = (float) (300 * Math.sin(thta));
    return y;
}
/**
 * 
 *
 * @param thta ()
 * @return x()
 */
private float x(Float thta) {
    float x = (float) (400 * Math.cos(thta));
    return x;
}

3.:x=a(cos2 )cos ,y=a(cos2)sin
/**
 * :y=a(cos2)sin
 *
 * @param thta ()
 * @return y()
 */
private float y(Float thta) {
    float y = (float) (200 * Math.sqrt(Math.cos(2*thta))*Math.sin(thta));
    return y;
}

/**
 * :x=a(cos2 )cos
 *
 * @param thta ()
 * @return x()
 */
private float x(Float thta) {
    float x = (float) (200 * Math.sqrt(Math.cos(2*thta))*Math.cos(thta));
    return x;
}

1.

: ...? : [-360,450]8101px1px dydy

2px


2.
P
()P'P
P[]
[]
xn,xn+1[dxn]
dxn[]
pn,pn+1[dpn]

3.
/**
 * 
 * @return
 */
private float dis(float x0, float y0, float x1, float y1) {
    return (float) Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
}
/**
 * ,xf(x)
 */
private void map() {
    Df.forEach(x -> {
        float dis = dis(x, f(x), x + 1, f(x + 1));//
        if (dis < mLineWidth && dis > mLineWidth / 2) {
            funMap.put(x, f(x));
        }
    });

4.
/**
 * ,xf(x)
 */
private void map() {
    Df.forEach(x -> {
        float dis = dis(x, f(x), x + 1, f(x + 1));//
        if (dis < mLineWidth && dis > mLineWidth / 2) {
            funMap.put(x, f(x));
        } else if (dis > mLineWidth) {
            float num = dis / mLineWidth;//
            for (float di = 0; di <= num; di += (1.f / num)) {
                x += di;
                funMap.put(x, f(x));
            }
        }
    });
    //
}

1.
Ak0
:A
:
:T=2/ 
:f=1/T=/2
:x+
:
y=k
|A|
-|A|

2.A:``

90,/2,360,2

2.1A=300

2.2A=100

2.3:
"" 
""

3.:``
3.1=2

3.2=5

3.3
"" 
""

=2 T = 2/ =  , 
f = 1/T = 1/

4.x=0
4.1:=/6

4.2:=/2

4.3:
:/

5.k``
5.1:k=100

5.2:k=200

k=200.png

5.3:
k

,


| || ---|---|---|--- | | | | | | | | | | | | | | |


1.

| | ---|---|--- V0.1-github|2018-1-2|Android

2.

| QQ|| ---|---|---|---| | 1981462002|zdl1994328| github|||

3.

1----, 2---- 3---- 4----


Related Projects