# Collisions (ohysics) for Missiles, Bullets, Explosions etc

#49

It’s worth looking into HOW normalizing works, because normalizing crops up in a few places other than just basic vector math, and its meaning is the same

#50
``````void Normalize()
{
float lenSquared = LengthSquared();
if (!Urho3D::Equals(lenSquared, 1.0f) && lenSquared > 0.0f)
{
float invLen = 1.0f / sqrtf(lenSquared);
x_ *= invLen;
y_ *= invLen;
z_ *= invLen;
}
}
Vector3 Normalized() const
{
float lenSquared = LengthSquared();
if (!Urho3D::Equals(lenSquared, 1.0f) && lenSquared > 0.0f)
{
float invLen = 1.0f / sqrtf(lenSquared);
return *this * invLen;
}
else
return *this;
}
``````

these are from engine source

#51

lets pause here, gotta have my dinner

#52

cool man, we’ll pick this up later, I’ll like you to try to explain what normalizing is and how it works given you can see the code. It’s basic stuff for me, and I’m pretty laid back and happy to share my brain, lots of people have contributed to my learning experience, I want to pay it forward.

#53

I really have to say, what a pile of shit, that sourcecode is, before I even begin to explain how it really works - I hate API that hide math behind constructs like that - no mention of a dot product

``````float lenSquared = LengthSquared();
``````

That hideous looking thing, is really, float lenSquared = dot (this vector, and also this vector);
One thing we do learn on the way, is that the dot product of a vector with itself, is its squared length, which we can only learn, by learning how the math works.

#54

Wrapping reused code in a function is common practice in object oriented programming.
Indeed this does not conserve mathematical elegance.

#55

I use oop as I see fit, I am starting to mix pure c with urho, because I am lazy, and because I am lazy like a fox
off topic police will be here any moment

#56

game development is not my passion, its my calling, I trained for this with robots spitting hot metal at me, getting the decimal point in the wrong place in one line of code caused the 30 foot long monster to try to tear itself apart, it was not acceptable to make mistakes

#57

Yet oh so tempting.

#58

ok so sometimes, I would stall the motor, and warm up my lunch on it

#59

robots have a sense of humour, and put up with a lot of shit, except putting the decimal point in the wrong place, this is the cardinal sin - I coded up to seven axes, which is just like a bone hierarchy in a game

#60

its really hard man, to code for many axes, when theres hammers smashing everywhere around you - and not make any mistakes, no errors, no floating point issues, no dot in the wrong spot

#61

I was pondering earlier today how a proper AI might only be able to laugh uncontrollably (mainly at us) after it took in enough information.

#62

I wish I could show you my work on gpu nnai for games, it scared the shit out of me

#63

we’re wayyy off topic, take it to pm

#64

#65

lets back to this very basic question, should we?

#66

Elaborating on my earlier post:

So you could multiply the mass of the bullet by it’s speed and apply that force to the target hit. That would be somewhat realistic. But you may want to increase the force and throw realism out the window, like they do in Hollywood, making a single bullet throw a person through the air.

#67

ok so we have a ray, it has a direction, and theoretically infinite length, but for the purposes of working out the force, we have direction, mass, and force, where force is, in terms of guns, related to the exit velocity - we can compute the force that left the gun, apply drag and friction and any other slowdowns, and at the end of its travel, when it hits the target, we can make some assumptions, based on what we think we know about physics - its a game, we get to play with the input values, and make them plausible in our game - wait thats wrong, we need to make the OUTCOME plausible, and how we did it, what math cheats we took, are not relevant to the user

#68

the magic in the magic show, is not in the hand or hat of the magician, its in his assistants underwear, its mostly slight of hand, doing the actual math is too slow, so we find ways to approximate it and get it done, getting shit done is the word of mouth way the game industry works, if you can get shit done, you get a job, and if you cant, you get the sack, its not a perfect world - but you can learn real magic from people around you, and apply it