|
|
|
|
昨天完成的向量积件 |
| 作者:佚名 来源:闪吧 作者: 200398sb40whb 更新:2007-1-13 20:36:26 错误报告 我要投稿 |
|
var x0:Number = zb_mc._x; var y0:Number = zb_mc._y; var x_d:Number = zb_mc._width/16; var y_d:Number = zb_mc._height/16; var a_array:Array = new Array(); var b_array:Array = new Array(); var i:Number = 0; var j:Number = 0; //计算向量角度的函数: function jd(x1:Number, y1:Number, x2:Number, y2:Number) { var d:Number = Math.sqrt(Math.pow(x2-x1, 2)+Math.pow(y2-y1, 2)); var jiaodu:Number = Math.abs(Math.acos((x2-x1)/d)*180/(Math.PI)); if (y1>y2 && x1<x2) { return 90-jiaodu; } else if (y1>y2 && x2<x1) { return 90-jiaodu; } else if (y1<y2 && x1>x2) { return 90+jiaodu; } else if (y1<y2 && x1<x2) { return 90+jiaodu; //y上半: } else if (y1>y2 && x1 == x2) { return 90-jiaodu; } else if (y1<y2 && x1 == x2) { return 90+jiaodu; } else if (y1 == y2 && x1<x2) { return 90+jiaodu; } else if (y1 == y2 && x1>x2) { return 90-jiaodu; } } // function xl_hs(x1:Number, y1:Number, x2:Number, y2:Number):Void { _root.lineStyle(1, 0x0000ff, 100); _root.moveTo(x0+x1*x_d, y0-y1*y_d); _root.lineTo(x0+x2*x_d, y0-y2*y_d); _root.attachMovie("dot", "dot"+j, j); _root["dot"+j]._rotation = jd(x0, y0, x0+x2*x_d, y0-y2*y_d); _root["dot"+j]._x = x0+x2*x_d; _root["dot"+j]._y = y0-y2*y_d; _root.createTextField("t"+j, 10+j, x0+x2*x_d, y0-y2*y_d, 60, 30); if (!jiaf.selected && !jianf.selected) { _root["t"+j].text = "("+a_array[i]+","+b_array[i]+")"; } else if (jiaf.selected) { _root["t"+j].text = "("+(a_array[i]+a_array[i-1])+","+(b_array[i]+b_array[i-1])+")"; } } function qd_hs():Void { a_array[i] = Number(abl); b_array[i] = Number(bbl); if (!jiaf.selected && !jianf.selected) { xl_hs(0, 0, a_array[i], b_array[i]); } else if (jiaf.selected) { i--; xl_hs(0, 0, (a_array[i-1]+a_array[i]), (b_array[i-1]+b_array[i])); _root.lineStyle(1, 0xff0000, 80); _root.moveTo(x0+a_array[i-1]*x_d, y0-b_array[i-1]*y_d); _root.lineTo(x0+(a_array[i-1]+a_array[i])*x_d, y0-y_d*(b_array[i-1]+b_array[i])); _root.moveTo(x0+x_d*a_array[i], y0-y_d*b_array[i]); _root.lineTo(x0+x_d*(a_array[i-1]+a_array[i]), y0-y_d*(b_array[i-1]+b_array[i])); } else if (jianf.selected) { i--; _root.lineStyle(1, 0x000000, 100); _root.moveTo(x0+a_array[i]*x_d, y0-b_array[i]*y_d); _root.lineTo(x0+a_array[i-1]*x_d, y0-b_array[i-1]*y_d); _root.moveTo(x0, y0); _root.lineTo(x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i])); _root.attachMovie("dot", "dot"+j, j); _root["dot"+j]._x = x0+x_d*(a_array[i-1]-a_array[i]); _root["dot"+j]._y = y0-y_d*(b_array[i-1]-b_array[i]); _root["dot"+j]._rotation = jd(x0, y0, x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i])); _root.createTextField("t"+j, 10+j, x0+x_d*(a_array[i-1]-a_array[i]), y0-y_d*(b_array[i-1]-b_array[i]), 60, 30); _root["t"+j].text = "("+(a_array[i-1]-a_array[i])+","+(b_array[i-1]-b_array[i])+")"; } abl = ""; bbl = ""; i++; j++; } // qd_btn.onPress = function() { qd_hs(); }; cz_btn.onPress = function() { for (n=0; n<j; n++) { _root["dot"+n].removeMovieClip(); _root["t"+n].text = ""; } i = 0; j = 0; a_array.splice(0, a_array.length); b_array.splice(0, b_array.length); _root.clear(); jiaf.selected = false; jianf.selected = false; }; _root.my_mc.onPress = function() { getURL("mailto:98sb40whb@163.com"); };
|
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
| 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
|
|
|
|