Hello all,
Is there any way to convert, what i think is, source code in C into C#?
Can't find any resources online for doing it anyways.. just C# to VB.net and
vice-versa.
The problem with the source code i have is it's quite difficult to
understand as they use some built in functions, such as DotProd and Normal,
which i reckon are in C# but not with the same parameter supplies as below.
For example - for DotProd below, it provides 4 parameters but the DotProd in
C# only allows you to supply a vector.
Little areas like this are catching me out!
Anyone help me convert / make sense of some of the source code below,
especially DotProd and Normal?
Thanks all.
Brian
-------------------------------------------------------------------------------------------------------------
Below is the source code.. it's to perform a collision between two balls of
equal mass.
void collision (void)
{
// ball movement (Yes?)
x1 += xVect1;
y1 += yVect1;
x2 += xVect2;
y2 += yVect2;
// test for collision
if (distance > radius1 + radius2)
{
return;
}
// if we get here, the balls have collided,
// so we do the collision calculations
xVelocity = xVect2 - xVect1;
yVelocity = yVect2 - yVect1;
// Normalize
Normal (x1 - x2, y1 - y2, normal);
approach = DotProd(normal[0], normal[1], xVelocity, yVelocity);
// calculate velocity change
xNewVect = normal[0] * approach;
yNewVect = normal[1] * approach;
// change velocities
xVect1 += xNewVect;
yVect1 += yNewVect;
xVect2 -= xNewVect;
yVect2 -= yNewVect;
}