Hello friends,
I'm developing a billiard game and I have a problem with ApplyImpulse method. Please check the following image:

The code of the each ball is:
Here is how I calculate the b2Vec which I'm using in ApplyImpulse:
_sightXPos and _sightYPos are the coords of point B (on the image), _cueBall.xPos and _cueBall.yPos are the coords of point A.
So my question is why the ball goes on the white line path and not on the black line path.
P.S.
there is no gravity on the scene
I'm developing a billiard game and I have a problem with ApplyImpulse method. Please check the following image:

The code of the each ball is:
Code:
var friction:Number = 0.05;
var density:Number = 1;
var resituttion:Number = 0.8;
var linearDumping:Number = 0;
var body:b2Body;
var bodyDef:b2BodyDef;
var boxShape:b2CircleShape;
bodyDef = new b2BodyDef();
bodyDef.type = b2Body.b2_dynamicBody;
bodyDef.position.Set(xPos / _drawScale, yPos / _drawScale);
bodyDef.bullet = true;
boxShape = new b2CircleShape(_ballRadius / _drawScale);
var fixtureDef:b2FixtureDef = new b2FixtureDef();
fixtureDef.shape = boxShape;
fixtureDef.friction = friction;
fixtureDef.density = density;
fixtureDef.restitution = resituttion;
body = _world.CreateBody(bodyDef);
body.SetFixedRotation(true);
body.SetSleepingAllowed(true);
body.SetBullet(true);
body.CreateFixture(fixtureDef);
body.SetLinearDamping(linearDumping);
Please note that I set the linearDumping to 0, because of the testing purpose. To make the ball's movement close to the real billiard ball the linearDumping should be high. var density:Number = 1;
var resituttion:Number = 0.8;
var linearDumping:Number = 0;
var body:b2Body;
var bodyDef:b2BodyDef;
var boxShape:b2CircleShape;
bodyDef = new b2BodyDef();
bodyDef.type = b2Body.b2_dynamicBody;
bodyDef.position.Set(xPos / _drawScale, yPos / _drawScale);
bodyDef.bullet = true;
boxShape = new b2CircleShape(_ballRadius / _drawScale);
var fixtureDef:b2FixtureDef = new b2FixtureDef();
fixtureDef.shape = boxShape;
fixtureDef.friction = friction;
fixtureDef.density = density;
fixtureDef.restitution = resituttion;
body = _world.CreateBody(bodyDef);
body.SetFixedRotation(true);
body.SetSleepingAllowed(true);
body.SetBullet(true);
body.CreateFixture(fixtureDef);
body.SetLinearDamping(linearDumping);
Here is how I calculate the b2Vec which I'm using in ApplyImpulse:
Code:
var h:Number = Math.sqrt(Math.pow(_sightXPos - _cueBall.xPos, 2) + Math.pow(_sightYPos - _cueBall.yPos, 2));
var x:Number = Math.sin((_sightXPos - _cueBall.xPos) / h);
var y:Number = Math.sin((_sightYPos - _cueBall.yPos) / h);
ball.body.ApplyImpulse(new b2Vec2(x, y), ball.body.GetPosition());
var x:Number = Math.sin((_sightXPos - _cueBall.xPos) / h);
var y:Number = Math.sin((_sightYPos - _cueBall.yPos) / h);
ball.body.ApplyImpulse(new b2Vec2(x, y), ball.body.GetPosition());
_sightXPos and _sightYPos are the coords of point B (on the image), _cueBall.xPos and _cueBall.yPos are the coords of point A.
So my question is why the ball goes on the white line path and not on the black line path.
P.S.
there is no gravity on the scene