physics - Vector Equation Implementation -


after time searching, have revised question.

i have found numerous examples of ball ball collisions, ones seem work use vector2d or vector2d.

this problem, because allowed use regular java library, main question is: how convert examples (which post below) use can use?

i have several variables, both balls have same mass, velocities broken different variables, x , y. have access x , y pos.

this problem left in application.

i @ total loss on how convert below example.

// mtd vector2d delta = (position.subtract(ball.position)); float d = delta.getlength(); // minimum translation distance push balls apart after intersecting vector2d mtd = delta.multiply(((getradius() + ball.getradius())-d)/d);    // resolve intersection -- // inverse mass quantities float im1 = 1 / getmass();  float im2 = 1 / ball.getmass();  // push-pull them apart based off mass position = position.add(mtd.multiply(im1 / (im1 + im2))); ball.position = ball.position.subtract(mtd.multiply(im2 / (im1 + im2)));  // impact speed vector2d v = (this.velocity.subtract(ball.velocity)); float vn = v.dot(mtd.normalize());  // sphere intersecting moving away each other if (vn > 0.0f) return;  // collision impulse float = (-(1.0f + constants.restitution) * vn) / (im1 + im2); vector2d impulse = mtd.multiply(i);  // change in momentum this.velocity = this.velocity.add(impulse.multiply(im1)); ball.velocity = ball.velocity.subtract(impulse.multiply(im2)); 

here url question:

http://stackoverflow.com/questions/345838/ball-to-ball-collision-detection-and-handling 

and have taken @ source code.

thank taking time read issue.

success!

i have found how use vector2d, , works perfectly! edit later answer!

i'm implementing own 3d engine in c# based on basic 3d open-source engine in javascript called a3. don't know if have 100% understand sounds can find examples vector2d not allowed use class?

i case, can imagine javascript not have native vector2d types had implement. don't afraid of giving try, few high school maths functions, should able implement own vector2d class in few minutes

the following link contain implementations if vector2d, vector3d, vector4d, matrix3, , matrix4 in javascript: https://github.com/paullewis/a3/tree/master/src/js/core/math hope helps :)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -