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

#47

It throws away the Magnitude, and forces the vector to have a length of 1, so now its just a direction

#48

This is a useful thing, but often abused, all it does, is turn any vector, into a direction vector

#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.