Page 1 of 1

Phunlet-safe homing missile prototype

PostPosted: Sun Nov 29, 2009 7:20 pm
by RA2lover
just a techdemo of it. again

Rating: rated 6.7
Filesize: 29.61 kB
Comments: 9
Ratings: 5
download


old version
Rating: rated 6.5
Filesize: 42.97 kB
Comments: 7
Ratings: 4
download


i'll continue its work, this time with moving targets.

Re: Phunlet-safe homing missile prototype

PostPosted: Sun Nov 29, 2009 8:33 pm
by KarateBrot
The quadrant change can be fixed easily but I use another formula to calculate the angle.

Code: Select all
angle = math.acos(e.normal(0)); e.normal(1) < 0 ? {angle = 2*math.pi - angle} : {}

The result will be a value in radians from 0 to 2*Pi. If you want to use it in your rocket type (-1)*e.normal instead of e.normal because of the position of the laser (it's backwards. e.normal will be pointing to the left which results in 180°). So (-1)*e.normal will correct it and turn e.normal to the right.

Now for calculating the difference between angle and targetangle you have to add a little code to fix the leak between the lower and upper right quadrant.
Code: Select all
anglediff = angle - targetangle;
anglediff > math.pi ? {anglediff = anglediff - 2*math.pi} : {anglediff < (-1)*math.pi ? {anglediff = anglediff + 2*math.pi} : {}}


This will give you perfect angles and angle differences without any leaks or random spinning.

I made an example for it:
Rating: rated 5
Filesize: 21.01 kB
Comments: 3
Ratings: 1
download

Re: Phunlet-safe homing missile prototype

PostPosted: Sun Nov 29, 2009 9:22 pm
by RA2lover
Scene edited. again. added (not-so)simple shaped charge warhead. it originally had tracers, but it lags too much when adding them(96 new entities requires a little too much computing power)

Re: Phunlet-safe homing missile prototype

PostPosted: Mon Nov 30, 2009 11:04 pm
by KarateBrot
you could also try another thing that came to my mind in august when I was thinking about a missile guidance system for v2.0 of my Javelin project:
Instead of calculating the angle of the rocket try to calculate the velocity angle of your rocket. Until now the rocket misses the target if it moves or has to turn too much. With the velocity angle instead of the position angle the missile will correct the direction of movement until velocity angle and target angle are the same so it will (nearly) hit the target (if everything I thought about is working)

Edit:
Hmm... maybe won't work when I think about it again but it's worth a try.

Edit2:
I made a missile guidance formula that's exactly doing that. Now that I'm much more experienced in physics and after deriving a stable mathematical model (it's convergent) I can say my guess from two years ago was right :D

lol just edited this old post because I'm bored. no one will notice it anyway

Re: Phunlet-safe homing missile prototype

PostPosted: Tue Dec 01, 2009 2:21 am
by RA2lover
worked worse after trying a polar projection(source = missile pos, distance = vel, angle = vel angle) as the point 2 for the angle(P1 = horizon, P3 = target)used for aiming the missile - especially when vel is greater than distance :mrgreen:(which is what i think you wanted to say) , but i'll look into that later.

Re: Phunlet-safe homing missile prototype

PostPosted: Wed Dec 16, 2009 7:50 pm
by RA2lover
made another part of the puzzle to be solved. next step is to mantain its accuracy when attacking moving targets, by predicting where it will be after some time.

Rating: rated 6.7
Filesize: 29.61 kB
Comments: 9
Ratings: 5
download

Re: Phunlet-safe homing missile prototype

PostPosted: Wed Dec 16, 2009 8:39 pm
by KarateBrot
it's not aiming at moving objects correctly?

Re: Phunlet-safe homing missile prototype

PostPosted: Wed Dec 16, 2009 8:54 pm
by RA2lover
it's still able to aim at movingobjects, hovewer with limited accuracy, as i didn't add the target position projection yet

Re: Phunlet-safe homing missile prototype

PostPosted: Thu Dec 17, 2009 4:07 am
by KarateBrot
Image

I just made this formula. It calculates the position the rocket has to aim at. It's for stationary and also moving targets. I'm not sure if it's 100% precise because in real life it wouldn't. But because algodoo calculates with finite small time steps and not infinite small time steps I'm pretty sure it's the exact formula.

Edit:
I have to extend the formula. Δt is not the time between two simulation steps. It could be but that's not what I wanted. It would only calculate where the target will be relative to the rocket in the next calculation. I need a bit more time.

Edit2:
It works just fine with a new Δt. It hits the target every time. And accuracy can still be improved by taking acceleration into account which is the next step.

- - - - -

P_aim: The position the rocket has to aim at (Target position projection)
P_t: Position of the target
v_t: velocity of the target
v_o: velocity of your rocket
Δt: time between two calculations