Work out impact angle for armour system

So I randomly thought of making some armour system for tanks as a fun thing to do but then of course not many tanks have 90 degree armour so then that’s where the relative armour thickness comes into play.

image

I can’t figure out the impact angle at all I don’t use Vectors much and that is most definitely the solution, I’ve tried trigonometry but that wouldn’t work, literally all I need is a way to figure out the impact angle shown above, any help is appreciated.

Also the direction of impact would be different every time it wouldn’t be a straight line.

2 Likes

You can get the angle between the normal vector and the velocity of tbe bullet projectile.

Explanation:

Normal vector is the red arrow labeled n with an arrow on top as it is a vector.

Velocity is the blue arrow, this assumes the bullet is facing in the direction it is traveling which is most of the time true.

Getting the angle theta (red circle with the slash in the middle) between them is the acos and dot product part of the script (vector trigonometry)

Then math.pi/2 or 90° is subtracted to get angle of impact as the surface of the plate is perpendicular to the normal vector. This is known as complemetary angles in trigonometry.

1 Like

Thank you very much I’ll try this in a bit and reply once I do.

Quite a stupid question I assume but what Vector would I use :Dot on, same with the Vector should I use .Velocity?

Shouldnt matter which vector, it’ll be the same. This is because dot product is commutative.

For more info on getting angle between two vectors:

You could or use AssemblyLinearVelocity.

The difference is when accounting for rotational velocity which should also cause an increase in local velocity at a point.

1 Like
local impactPoint = script.Parent.ImpactPoint
local armourPart = workspace.Part3

local norm = armourPart.CFrame:VectorToWorldSpace(Vector3.FromNormalId(Enum.NormalId.Front))
local aoi = math.pi/2 - math.acos(-armourPart.Position:Dot(impactPoint.AssemblyLinearVelocity, norm))

I currently have this but no matter what I change the AOI output is always 0deg, meaning the acos is 90.

I’ve changed many things but to no avail, is there something obvious I’m missing?

Make sure to unitize vectors to calculate the angle correctly using .Unit to set the magnitude length to one while keeping the direction.

1 Like

I tried that still doesn’t change much either makes it nan or just 90.

Edit: The Velocity is 0 which makes the Unit return NaN

Edit 2: I fixed it, thank you a lot for your help.

Edit 3: Everything works normally except from when the armour is angled at 90 degrees it goes to a ridiculously high number, as expected using tangent instead fixes this and gives an accurate result, how would I differentiate these and tell the script to use tangent or cosine?

1 Like

Nice work with resolving the NaN error.

For the big angle problem one of the possible reasons is that it will measure the angle phi instead which is the green label. I think you can just counteract it by seeing if the angle is more than 90 degrees if so then you can minus 90 degrees.

image