關于最后一節(jié)的問題
function sameSign(a,b){
return (a ^ b)>=0;
}
function vector(a,b) {
return{
x:b.x-a.x,
y:b.y-a.y
}
}
function vectorProduct(v1,v2) {
return v1.x * v2.y-v2.x * v1.y;
}
function isPointInTrangle(p,a,b,c){
var pa=vector(p,a);
var pb=vector(p,b);
var pc=vector(p,c);
var t1=vectorProduct(pa,pb);
var t2=vectorProduct(pb,pc);
var t3=vectorProduct(pc,pa);
return sameSign(t1,t2)&&sameSign(t2,t3);
}
function needDelay(elem,leftCorner,currMousePos){
var offset=elem.offset();
var topLeft={
x:offset.left,
y:offset.top
}
var bottomLeft={
x:offset.left,
y:offset.top+elem.height()
}
return isPointInTrangle(currMousePos,leftCorner,topLeft,bottomLeft);
}
我運行時候一直顯示
function vector(a,b) {
return{
x:b.x-a.x,
y:b.y-a.y
}
}
這個里面的x不能是undefined的屬性?
2017-06-03
我也遇到了這個問題,然后回頭再看一遍,找出了兩個問題:
#test 的第一個mouseenter方法下的第二行代碼為:$(document).bind('mousemove',moveHanlder);開始寫的unbind
第二個就是我下面多謝了一個timer = setTimeout(function(){......}
2017-05-25
我也是遇到同樣的問題,x是undefined,,請問這是怎么回事
2017-05-17
function vector(a,b){
return{
? ?x: b.x - a.x;
y: b.y - a.y
}
}
為什么總是報錯
2017-05-06
方法本身沒有問題,可能是你傳的p,a,b,c對應的實參currMousePos,leftCorner,topLeft,bottomLeft坐標有問題,可以打印出來瞅瞅。