It is correct indeed, But it won't hurt if you test it with a trivial triangle like the ABC (1,0) (0,1) (1,1) thats the isosceles rectangle-triangle that has a2 = 45° angle, so it should yield the same for the last equation step
Suppose (1,0) "d" (0,1) "v1" and v2 = d + v1 or (1,1) the trickery here is that you have to take the Pythagoras geometric mean in order for them to fit in the arcsin argument, so Arcsin ( sqrt(1*1) *sin(90)) / sqrt(1*1+1*1) = arcsin(1/sqrt(2)) = 45°
Alternatively If you were wondering what are the d and t for, they are used to craft the v2 (x,y) vector by knowing its y components are always the same as in v1(y) component, (because that is the condition for them to impact) and that vector (x) component is given by Distance that is Bullet Speed (x) * t, minus the v1(x) components ( because thats is how you make a line or make vectors from 2 points) you get v2= (d(x)-v1(x) , v1(y))
and to get the angle of a vector you just feed it to an arctan as (Y/X) so arctan(v1(y) / (d(x)-v1(x)) ... which in the trivial isosceles triangle its equivalent to just add arctan( v2) = arctan (1,0)+(0,1) = arctan (1,1) = arctan (1/1) = 45°
It is correct indeed, But it won't hurt if you test it with a trivial triangle like the ABC (1,0) (0
Note: if you don't multiply every vector by the same value of t, its still like if you would have done so for a t = 1 so you either multiply everything by a given t value or you just don't
Note: if you don't multiply every vector by the same value of t, its still like if you would have do
thats ok, don't worry, If t is unknown you can either leave it as a variable and just write them algebraic as v*t or just solve for t as distance(x) + v2(x)*t - v1(x)*t = 0 where zero is the condition for they to meet,
hint 3 if bullet speed is a constant than its a polar velocity whose vector component v2(x,y) = (speed * cos(Θ), speed sin (Θ)) where Θ is just a2) where we already know that speed sin(Θ) must be the same speed of v1(y) in order for them to impact so solving for v2(x) on a pythagoras geometric mean, sqrt( (v2(x) -v1(x))² + v1(y)² ) = bullet speed, that would correlate the (x,y) speed needed for a collision, you would still need to add later a compensation for distance as (x)/t as and added x speed, Or just by shooting t seconds early in distance(x) v(x)t - v2(x)t = 0
thats ok, don't worry, If t is unknown you can either leave it as a variable and just write them al
also for the shooting early case you would need to make an assumption if v(2) is 0 until bullet speed (x)*t' matches distance in which case v2(y) would need to be recalculated as an "arithmetic mean"(v2+0)*(t/(t+t')) as you want that to become slower if and if speed is preserved, (v2)*(t/(t-t')) as you would want to grow faster
also for the shooting early case you would need to make an assumption if v(2) is 0 until bullet spee
sqrt( (v2(x) -v1(x))² + v1(y)² ) = bullet speed + a tweak?I just forgot what I was doing here
lets tidy it up into an algebraic formulary simplified one sqrt( (v2(x)² + v1(y)²) = bullet speed v2(x) = sqrt((bullet speed)² - v1(y)²)) angle a2 = arctan (v1(y) / (sqrt((bullet speed)² - v1(y)²)))
as long as the vectors share the y component and y position along v2(x)>v1(x) they will intersect eventually then distance(x) + v1(x)t - v2(x)t = 0 v(x1-x2)t = -distance(x) t = -distance(x)/(x1-x2)
sqrt( (v2(x) -v1(x))² + v1(y)² ) = bullet speed + a tweak?I just forgot what I was doing here lets
Note 2, the above assumes that both the projectile and the target share the same starting y point position, as the picture implies, for distinct y positions v2(y) component needs to compensate for v1(y) speed, ie v2 (x,y) = (x,v1(y) + ((delta of y point of (player - enemy position)/time of impact)) those points are unnamed so they likely are inconsequential
Note 2, the above assumes that both the projectile and the target share the same starting y point po