我正在构建一个应用程序,该应用程序使用 Dave DeLong 的 DDMathParser 绘制文本给定函数。我需要知道(对于我评估的每个“x”)解决方案是否存在,或者它只给我 0.00,因为它无法评估它。也许是布尔?
while (x <= (viewWidth - originOffsetX)/axisLenghtX) {
NSDictionary *variableSubstitutions = [NSDictionary dictionaryWithObject: [NSNumber numberWithDouble:x] forKey:@"x"];
NSString *solution = [NSString stringWithFormat:@"%@",[[DDMathEvaluator sharedMathEvaluator]
evaluateString:plotterExpression withSubstitutions:variableSubstitutions]];
numericSolution = solution.numberByEvaluatingString.doubleValue;
NSLog(@"%f", numericSolution);
if (newline) {
CGContextMoveToPoint(curveContext, (x*axisLenghtX + originOffsetX), (-numericSolution * axisLenghtY + originOffsetY));
newline = FALSE;
} else {
CGContextAddLineToPoint(curveContext, (x*axisLenghtX + originOffsetX), (-numericSolution * axisLenghtY + originOffsetY));
}
x += dx;