Я пытаюсь создать график: 1 / (x Squared - 1)
Как видите, график выглядит красиво: ![enter image description here](https://i.stack.imgur.com/RoToD.png)
код ниже др aws график выше. Но я не хочу, чтобы вертикальные асимптоты отображались.
path.moveTo(valx, valy);
path.quadTo(x, y, middle2, middle);
path.lineTo(x, y); // I think this is what causes the vertical asymptotes to show
canvas.drawPath(path, points);
path.reset();
Глядя на линию path.lineTo выше, я вижу, что путь соединяет точки с линией. Вот почему рисуются вертикальные асимптоты.
Идея, которую я реализовал, заключается в следующем. В псевдокоде:
//split the x axis into regions and compute a limiting value for each region
Boolean drawMe = false;
//region1: those x values less than the first asymptote = -1
if(Float.compare(x values , first asymptote = -1) < 0 && Float.compare(absolute value of
(Math.abs(x value) - Math.abs(first asymptote) , 0.01f ) > 0)drawMe = true
//region2: those x values between both asymptotes which are -1 and 1:
if(Float.compare(x values , first asymptote) > 0 && Float.compare(x values , second asymptote) < 0
&& Float.compare(absolute value of(Math.abs(x value) - Math.abs(first asymptote) , 0.01f) > 0
&& Float.compare(absolute value of(Math.abs(x value) - Math.abs(second asymptote) , 0.01f) > 0)
drawMe = true;
//region3: those x values greater than the second asymptote = 1:
if(Float.compare(x values , second asymptote) > 0 && Float.compare(absolute value of(Math.abs(x value) - Math.abs(second asymptote) , 0.01f) > 0 ) drawMe = true;
if(drawMe){
path.moveTo(valx, valy);
path.quadTo(x, y, middle2, middle);
path.lineTo(x, y); // I think this is what causes the vertical asymptotes to show
canvas.drawPath(path, points);
path.reset();
}
Однако, разбивая ось x на области, мы получаем ту же самую вещь снова. Мне нужно найти способ остановить рисование асимптот, и я думаю, что большая проблема заключается в строке кода: path.lineTo
Любые предложения