将用户生成的折线图与程序随机生成的折线图进行比较
该程序将向学生显示折线图。学生必须使用箭头键将角色远离或靠近运动检测器来重新创建该线图,从而创建距离-时间图。我可以捕获程序在绘制图形时生成的数据点。我还可以捕获学生生成的数据点。如何比较这两个图表,同时允许学生有一定的容忍度?我是否应该在绘制图表时或记录所有数据点后尝试检测不正确的图表?虽然有些图表是线性的并且易于比较,但其他图表将是分段函数,具有随机间隔的正斜率、负斜率和零斜率。
谢谢!
The program will show the student a line graph. The student will have to recreate that line graph by moving a character away from or toward a motion detector using the arrow keys, creating a distance-time plot. I can capture the data points that the program generates when drawing its graph. I can also capture the data points gnerated by the student. How can I compare the two graphs while allowing for some tolerance on the student's part? Should I try to detect incorrect graphs as they are being drawn or after all data points are recorded? While some of the graphs will be linear and easy to compare others will be piecewise functions with positive, negative, and zero slopes at random intervals.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
绘制图表线的顺序重要吗?
您可以将具有特定阈值的点记录到数组/向量中并进行比较。
一种快速而肮脏的方法是使用 2 个二进制(单色,只是黑白)图像:
用户/学生绘图的地方(按下鼠标时)。
例如
,当绘图完成时(释放鼠标或您设置的任何规则),
您运行一个函数来检查源(原始图)图像中有多少黑色像素
在目标(用户图)图像中匹配。
您可以创建一个包含在差异模式下混合的其他两个位图的 BitmapData,因此任何非黑色的内容都不匹配,或者只需循环遍历所有像素一次并手动检查像素是否匹配。请注意,这依赖于两个图像的尺寸(宽度,高度)相同的事实。
下面是一些代码来说明这一点:
向量/数组版本将是类似的,但不会有视觉提示。根据您的设置,您可能想要测试哪一个最适合您:BitmapData 比数组占用更多内存,但您可以轻松创建位图,将其添加到显示列表并检查看起来是否正确等。
如果速度是一个重要因素,问题:
你可能会用一个循环而不是两个循环
例如
var Pixels:int = source.width * source.height;
for(pixels;pixels >=0;pixels--)
HTH
Does the order in which the graph lines are drawn matter ?
You could record the points with a certain threshold into an Array/Vector and compare.
A quick'n'dirty way would be using 2 binary(monochrome, just black and white) images:
where the user/student draws(has the mouse while it's pressed).
e.g.
When the drawing is complete(either the mouse is released or whatever rule you set),
you run a function that checks how much black pixels from the source(original graph) image
are matched in the destination(user graph) image.
Either you create a BitmapData containing the other two bitmaps blended on Difference mode, so anything that isn't black is not a match, or just loop through all the pixels once and manually check if the pixels match. Note that this relies on the fact that dimensions(width,height) of the two images are the same.
Here's a bit of code to illustrate this:
The Vector/Array version would be similar, but there would be no visual cues. Depending on your setup, you might want to test which would work best for you: BitmapData takes more memory than Arrays, but you can easily create a Bitmap, add it to the display list and check if looks right, etc.
If speed is an issue:
you probably get away with one loop instead of two
e.g.
var pixels:int = source.width * source.height;
for(pixels; pixels >=0; pixels--)
HTH