- #1
Orianna
Hello,
I'm working on a (private) Software Project and Part of that is finding a Way to Predict Projectile Positions. My thought's are explained from a Code View a little bit, but I tried to clarify everything so everyone could understand what's going on.
(It's my first time in this Forum, I hope i posted in the right Section)
Data Available
Target.Position (Vec3 x, y, z)
Target.minVelocity (float)
Target.maxVelocity (float)
Target.Accel (float)
Target.Width (integer/float)
Projectile.Position (Vec3 x, y, z)
Projectile.minVelocity (float)
Projectile.maxVelocity (float)
Projectile.Accel (float)
Projectile.Delay (integer)
Projectile.Range (integer; Only Relevant if Target Outruns Projectile)
Projectile.Width (integer/float)
Extra.Delay (integer, usually 1ms to 80ms)
Process
^This is what I've got so far.
targetDirection = Vector.Normalize(Target.Position - Projectile.Position)
targetVelocityOrth = Vector.Dot(Target.minVelocity, targetDirection) * targetDirection
targetVelocityTang = Target.minVelocity - targetVelocityOrth
float velSpeed = targetVelocityTang.Magnitude;
if (velSpeed > Projectile.minVelocity)
exit
else
float OrthSpeed = Sqrt(Projectile.Speed * Projectile.Speed - velSpeed * velSpeed)
Vec3 velOrth = targetDirection * OrthSpeed
Vec3 Result = targetVelocityTang + velOrth
float tCollision = ((Projectile.Position - Target.Position).Magnitude - Projectile.Width - Target.Width) / (velOrth.Magnitude-targetVelocityOrth.Magnitude)
Vec3 ProjectileVel = velOrth + targetVelocityTang
Vec3 PredictedPos = Projectile.Position + ProjectileVel * tCollision
"Problem"
Took me quite a while to figure out all of this (and a lot of Internet Searches) but now I'm stuck with a Solution that doesn't use Delay or Acceleration. How would one go further down the Road? I've read that Kinematic Equations are used for Acceleration, but which one exactly?
Basicly I'm just looking how to further progess with this algorithm/equation.
I'm working on a (private) Software Project and Part of that is finding a Way to Predict Projectile Positions. My thought's are explained from a Code View a little bit, but I tried to clarify everything so everyone could understand what's going on.
(It's my first time in this Forum, I hope i posted in the right Section)
Data Available
Target.Position (Vec3 x, y, z)
Target.minVelocity (float)
Target.maxVelocity (float)
Target.Accel (float)
Target.Width (integer/float)
Projectile.Position (Vec3 x, y, z)
Projectile.minVelocity (float)
Projectile.maxVelocity (float)
Projectile.Accel (float)
Projectile.Delay (integer)
Projectile.Range (integer; Only Relevant if Target Outruns Projectile)
Projectile.Width (integer/float)
Extra.Delay (integer, usually 1ms to 80ms)
Process
^This is what I've got so far.
targetDirection = Vector.Normalize(Target.Position - Projectile.Position)
targetVelocityOrth = Vector.Dot(Target.minVelocity, targetDirection) * targetDirection
targetVelocityTang = Target.minVelocity - targetVelocityOrth
float velSpeed = targetVelocityTang.Magnitude;
if (velSpeed > Projectile.minVelocity)
exit
else
float OrthSpeed = Sqrt(Projectile.Speed * Projectile.Speed - velSpeed * velSpeed)
Vec3 velOrth = targetDirection * OrthSpeed
Vec3 Result = targetVelocityTang + velOrth
float tCollision = ((Projectile.Position - Target.Position).Magnitude - Projectile.Width - Target.Width) / (velOrth.Magnitude-targetVelocityOrth.Magnitude)
Vec3 ProjectileVel = velOrth + targetVelocityTang
Vec3 PredictedPos = Projectile.Position + ProjectileVel * tCollision
"Problem"
Took me quite a while to figure out all of this (and a lot of Internet Searches) but now I'm stuck with a Solution that doesn't use Delay or Acceleration. How would one go further down the Road? I've read that Kinematic Equations are used for Acceleration, but which one exactly?
Basicly I'm just looking how to further progess with this algorithm/equation.