查找并标记两条线之间的交点
Find and mark the intersection between two lines
我有两个 CPTScatterPlots,我想找到它们的交点并在那里绘制一个带有填充的自定义圆。当然我可以手动计算它,但也许核心情节已经有了。
见附件
Core Plot 可以吗?
根据 Eric 的建议更新:
/* Add the plot symbol for the intersection */
CPTMutableLineStyle *symbolLineStyle = [CPTMutableLineStyle lineStyle];
symbolLineStyle.lineWidth = 2.;
symbolLineStyle.lineColor = [[CPTColor colorWithComponentRed:91./255. green:173./255. blue:221./255. alpha:1.] colorWithAlphaComponent:1];
CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
plotSymbol.fill = [CPTFill fillWithColor:[[CPTColor colorWithComponentRed:241./255. green:241./255. blue:241. /255. alpha:1.] colorWithAlphaComponent:1.]];
plotSymbol.lineStyle = symbolLineStyle;
plotSymbol.size = CGSizeMake(_CIRCLE_RADIUS, _CIRCLE_RADIUS);
dataSourceIntersectionPlot.plotSymbol = plotSymbol;
Core Plot无法为您找到交点,但可以标记出来。如果您知道线条将在其中一个数据点交叉,只需将绘图符号添加到其中一个绘图即可。在正确的索引处实施 -symbolForScatterPlot:recordIndex:
数据源方法和 return 符号。
如果线条可能在数据点之间交叉,请创建第三个图,仅用于突出显示交叉点。它只需要一个带有绘图符号的数据点——交点。
我有两个 CPTScatterPlots,我想找到它们的交点并在那里绘制一个带有填充的自定义圆。当然我可以手动计算它,但也许核心情节已经有了。
见附件
Core Plot 可以吗?
根据 Eric 的建议更新:
/* Add the plot symbol for the intersection */
CPTMutableLineStyle *symbolLineStyle = [CPTMutableLineStyle lineStyle];
symbolLineStyle.lineWidth = 2.;
symbolLineStyle.lineColor = [[CPTColor colorWithComponentRed:91./255. green:173./255. blue:221./255. alpha:1.] colorWithAlphaComponent:1];
CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
plotSymbol.fill = [CPTFill fillWithColor:[[CPTColor colorWithComponentRed:241./255. green:241./255. blue:241. /255. alpha:1.] colorWithAlphaComponent:1.]];
plotSymbol.lineStyle = symbolLineStyle;
plotSymbol.size = CGSizeMake(_CIRCLE_RADIUS, _CIRCLE_RADIUS);
dataSourceIntersectionPlot.plotSymbol = plotSymbol;
Core Plot无法为您找到交点,但可以标记出来。如果您知道线条将在其中一个数据点交叉,只需将绘图符号添加到其中一个绘图即可。在正确的索引处实施 -symbolForScatterPlot:recordIndex:
数据源方法和 return 符号。
如果线条可能在数据点之间交叉,请创建第三个图,仅用于突出显示交叉点。它只需要一个带有绘图符号的数据点——交点。