XNA Collision Detection - Vector2.Reflect - Help Calculating the Normal Sprite Environment - C #

I have problems with how to calculate the normal for a moving circle in the 2nd space. I figured out how much I suppose to calculate the Rate of Speed ​​(directional speed) rate of an object, but that when my college algebra mind overheats, I work with two circles that I have center, radius, speed and position.

Ultimately, I want to use the Vector2.Reflect method to get a little more realistic physics from this exercise.

thanks in advance.

EDIT: Added code for a trial offer (to no avail), possibly a misunderstanding of this offer. Here I use basketball and baseball, therefore, base and basket. I also have Position and Velocity, which are added to the position to create movement.

if ((Vector2.Distance(baseMid, basketMid)) < baseRadius + basketRadius)
{
    Vector2 baseNorm = basketMid - baseMid;
    baseNorm.Normalize();
    Vector2 basketNorm = baseMid - basketMid;
    basketNorm.Normalize();
    baseVelocity = Vector2.Reflect(baseVelocity, baseNorm);
    basketVelocity = Vector2.Reflect(basketVelocity, basketNorm);
}

basePos.Y += baseVelocity.Y;
basePos.X += baseVelocity.X;
basketPos.Y += basketVelocity.Y;
basketPos.X += basketVelocity.X;
basketMid = new Vector2((basketballTex.Width / 2 + basketPos.X), (basketballTex.Height / 2 + basketPos.Y));
baseMid = new Vector2((baseballTex.Width / 2 + basePos.X), (baseballTex.Height / 2 + basePos.Y));
+3
source share
3 answers

. , Vector2.Reflect . (0,1), (4, -3) (4,3). ? , if. ( , , basketNorm = -baseNorm.)

. , , , , , . : . , ? , , ( ). , , , . ? , ​​ , , , .

, ( , , , , ). . , :

Vector2 CMVelocity = (basket.Mass*basket.Velocity + base.Mass*base.Velocity)/(basket.Mass + base.Mass);

baseVelocity -= CMVelocity;
baseVelocity = Vector2.Reflect(baseVelocity, baseNorm);
baseVelocity += CMVelocity;

basketVelocity -= CMVelocity;
basketVelocity = Vector2.Reflect(basketVelocity, basketNorm);
basketVelocity += CMVelocity;
+5

. , , "" , ( ), :

- , - . A (B-A), B (A-B). , , , .

+1

: , . .

. - ( 1) , , , , .

, , ? , , , , .

, 2- , , * () . , , . , . , , , , , :)

, ( , , , ).

, , , . , , - , - .

It also involves perfectly elastic collisions.

If I am wrong, I would be glad to know where :)

0
source

Source: https://habr.com/ru/post/1731646/


All Articles