Hi guys,
Here's my problem...
I have a ball constructor Ball(x,y) and a line constructor Plane(x0,y0,x1,y1)
The norm of the line is defined as dx=x1-x0, and dy=y1-y0, where the normal vector is either norm(-dx,dy) or norm(dx,-dy)
In order the gauge the distance from the ball at some arbitrary position to the line/plane at some arbitrar position, I use the followin funcition:
float Plane::distToPlane(Ball &ball){
float dot_prod=(ball.getCricle().position.dot(normal));
return (dot_prod);
}
Everything works fine except the float that's returned I can't use. What I really need, is a as the ball is approaching the line, the distance get's closer and closer to zero, and right now it's not doing that.
I need to be able to do this check for any arbitrary line/ball position:
if(distance<0)//do this
I guess what I am really trying to say is that I need this....
float Plane::distToPlane(Ball &ball){
float dot_prod=(ball.getCricle().position.dot(normal)+SOME_OFFSET);
return (dot_prod);
}
Where the offset will always close the dot product to zero no matter where the ball and the line start.
I have been trying many different things but can't grasp the mathematical relationship.
If anyone has any idea on how to approach the problem, please let me know.
Thanks,
MIke