首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

zcy_dr高手.请帮下忙.该如何解决

2012-02-27 
zcy_dr高手.请帮下忙.HTML codeimg srcimages/1111.jpg width500 height300usemap#map_sample

zcy_dr高手.请帮下忙.

HTML code
<img src="images/1111.jpg" width="500" height="300"  usemap="#map_sample" border="0" /><map name="map_sample" id="map_sample"><area shape="poly" coords="284,47,270,88" href="#" /><area shape="poly" coords="340,164,304,123" href="#" /></map><script>function foo(pos1,pos2,pos3,pos4){var x,y;    if(pos1.x==pos2.x && pos1.y != pos2.y){        if(pos3.x==pos4.x && pos3.y != pos4.y)            return false;        x = pos1.x;        var k2 = (pos3.y-pos4.y)/(pos3.x-pos4.x);        var b2 = pos3.y - k2*pos3.x;        y = k2*x+b2;            }else if(pos3.x==pos4.x && pos3.y != pos4.y){        x = pos3.x;        var k1 = (pos1.y-pos2.y)/(pos1.x-pos2.x);        var b1 = pos1.y - k1*pos1.x;        y = k1*x+b1;    }else{            var k1 = (pos1.y-pos2.y)/(pos1.x-pos2.x);        var k2 = (pos3.y-pos4.y)/(pos3.x-pos4.x);                if(k1 == k2){            return false;        }                var b1 = pos1.y - k1*pos1.x;        var b2 = pos3.y - k2*pos3.x;                x = (b2-b1)/(k1-k2);        y = k1*x+b1;        }        if(((x<=pos1.x && x>=pos2.x) || (x<=pos2.x && x>=pos1.x)) && ((x<=pos3.x && x>=pos4.x) || (x<=pos4.x && x>=pos3.x)))        return {x:x,y:y};    else        return false;}//326,123,354,84var r = foo({x:284,y:47},{x:270,y:88},{x:340,y:164},{x:304,y:123});if(r)    alert("交点为:x:"+r.x+",y:"+r.y);else    alert("没有交点");</script>

可否将你这个再判断下。
当一条钱段的端点在另一条线段上。
也让他提示相交。并返回该端点。

[解决办法]
交点的x坐标为277688/1025,约等于270.9,不是任何一个端点

热点排行
Bad Request.