|
Post by Paradox on Apr 28, 2010 17:20:41 GMT -5
*Walks in, bad music plays* I am negative thoughts of XXX. Just so you know, time-based Forum Games don't work out. Ever think of time zones? One day for me may happen at a different time than you. See? Does it use any game mechanics based off of PW?
If you can answer these, I will join. If, of course, that's alright.
|
|
|
Post by microfarad on Apr 28, 2010 17:33:12 GMT -5
It does work because the game is updated only daily. People from all timezones have equal opportunity... PW was my inspiration. But it's totally different than PW.
NOW SOLVE FOR a2 FOR GOD'S SAKE!
|
|
|
Post by Qwerty on Apr 28, 2010 18:44:22 GMT -5
Where does that equation go, anyway?
|
|
|
Post by microfarad on Apr 29, 2010 11:58:19 GMT -5
In the Junebug program... DUH... Specifically, it goes in a function which determines which direction a ship should head in order to meet another ship... Actuall, if you want to get really specific... It goes here: Junebug.Fleet.DirToMeet
|
|
|
Post by General Veers on Apr 29, 2010 14:56:29 GMT -5
The following solution assumes that this will be applied to both "meeting" starcraft simultaneously, in which case you only need to know the positions of the ships, and that ships can only instantaneously change their angles and velocities. If you have one ship continue on its normal path while another ship decides to initiate the meeting (i.e. the solution does NOT apply to both ships simultaneously, but only on the ship that will change its course while the other ship will continue on its previous course), then that will require me to do slightly more work, albeit without the use of calculus. If you want both ships to gradually come together without instantaneously changing their angles or velocities, like in reality, then that will require me to work with differential equations. I don't care what you believe - if this is the kind of solution you want (realistically Newtonian solution), then differential calculus is inevitable. Don't argue with the birthday Administrator. If you want a realistically Einsteinian solution, too bad! I'm not familiar enough with General Relativity to figure out everything. Imagine two arbitrary points in the real (as opposed to complex) plane. One point would be A(x1, y1) and the other would be B(x2, y2).
If the shortest path between them is not parallel with one of the plane's axes, then make A and B the vertices of a right triangle whose third point is the right angle. If the shortest path is parallel with either of the plane's axes, then the angles must be 0, π/2, π, or 3π/2. It should be easy to test for what angles depending on whether one component of the distance is zero and the other component of the distance is positive or negative relative to a ship's distance from the origin.
Label the angle closest to A as α and the angle closest to B as β.
Now, the distance between points A and B should be ((x2 - x1)2 + (y2 - y1)2)1/2. The distance should be the length of the hypotenuse of the triangle.
By definition, the sine of α should be the cosine of β , and they should be equivalent to the y-component of distance divided by the hypotenuse. I.e., sin(α) = cos(β) = (y2 - y1) / ((x2 - x1)2 + (y2 - y1)2)1/2. Similarly, cos(α) = sin(β) = (x2 - x1) / ((x2 - x1)2 + (y2 - y1)2)1/2.
Naturally, take the inverse sine or the inverse cosine of both sides of the equation to find your desired angle. Hopefully, the signs from the numerator of the arcsine or arccosine should provide information as to the true angle relative to the polar axis.
Once you solve for both angles, override the old α with the solution α and override the old β with the solution β.
|
|
|
Post by microfarad on Apr 29, 2010 16:09:28 GMT -5
Woops! Lost me where you said sin(alpha)=cos(beta)
That is definitely not true, unless I'm missing something............
|
|
|
Post by General Veers on Apr 29, 2010 16:42:52 GMT -5
Alright, the sine of an angle is defined as the opposite side divided by the hypotenuse (H), no? The cosine of an angle is defined as the adjacent side divided by H, no? The side that is opposite relative to α is adjacent relative to β, and vice versa.
If δy is opposite α and adjacent to β, then (δy)/H is the leg opposite α divided by the hypotenuse AND is the leg adjacent to β divided by the hypotenuse. Ergo, sin(α) = (δy)/H = cos(β). Quot Erat Demonstratum.
|
|
|
Post by Qwerty on Apr 29, 2010 17:32:33 GMT -5
Long story short:
sin(alpha)=cos(beta) is a mathematical rule, provided the third angle is a right angle.
|
|
|
Post by microfarad on Apr 29, 2010 17:34:55 GMT -5
Well, I know THAT... But the third angle ISN'T a right angle... Not at all... Veers, what are you trying to do? I do not think you are solving the problem at hand...
|
|
|
Post by General Veers on Apr 29, 2010 18:09:10 GMT -5
If the shortest path between them is not parallel with one of the plane's axes, then make A and B the vertices of a right triangle whose third point is the right angle. Yes, I explicitly stated that the points should form a right triangle (which can be done by projecting the segment connecting the points onto the horizontal and vertical axes). I realize this is different from what you have, but depending on how you want your ships to behave, you may be able to disregard everything except position in order to solve for the angles the ships should have in order to go to each other. The rest of it is finding out where along the path the two ships would meet, given their separate speeds. So, explain how exactly you want the ships to behave. I can think of three scenarios, all of which I have described in my potential solution post. If none of those scenarios describe the motion of two ships that expect to approach each other, then what do you plan for their behavior?
|
|
|
Post by microfarad on Apr 29, 2010 18:14:43 GMT -5
Well, I do not want to change the course of ship A. If it is impossible for them to meet then I will test for that and ship B will travel parallel to ship A...
EDIT: Project Junebug is official canceled until somebody can get the answer. My dad is really "busy" so he can't help me...
|
|
|
Post by izacque on May 2, 2010 15:29:43 GMT -5
wait... so you want ship a to continue in a straight line and ship b to alter it's course so that it intercepts ship a? or do you want it to "follow" ship a? and do you want ship b to move in smooth curves? or are straight lines and angles okay?
|
|
|
Post by microfarad on May 2, 2010 16:05:08 GMT -5
Ship #1 located at arbitrary point (X1,Y1) traveling at arbitrary angle A1 moving at arbitrary speed V1
Ship #2 located at arbitrary point (X2,Y2) traveling at unknown angle A2 moving at arbitrary speed V2
Ships #1 and #2 must intersect at some time so that they occupy the same point at the same time. The trajectory of ship #2 (A2) is the only unknown value. Please find equation for A2, show your work so that I can verify that your answer is correct.
|
|
|
Post by General Veers on May 2, 2010 16:31:06 GMT -5
The following image does not yet knowingly apply. [img]http://i40.[tinypic.com]/219qmvm.png
[/img] [/center] I had to make the velocity and displacement vectors with respect to time so that I could ensure that, not only would the vectors meet at a particular point, but simultaneously as well.
Speeds
Speeda = A Speedb = B
Velocities
va(t) = <Acosα, Asinα> vb(t) = <Bcosβ, Bsinβ>
Displacements relative to the origin (i.e. Antiderivatives of Velocities)
∫va(t)dt = sa(t) = <Atcosα + xa, Atsinα + ya> ∫vb(t)dt = sb(t) = <Btcosβ + xb, Btsinβ + yb>
Entity A travels in the direction of α with a speed of A, starting at point (xa, ya) at time ti=0.
Entity B travels in the direction of β with a speed of B, starting at point (xb, yb) at time ti=0.
The values A, B, xa, ya, xb, yb, and α are arbitrary constants that cannot be changed during the course of the problem. The values β and t are variables whose values must be determined in order for entities A and B to cross the same location simultaneously (at time t). The variable t represents the time the paths cross, relative to the initial time when the entities started at their respective points.
If the locations of the two ships must be equivalent, then their displacements relative to the origin must be equivalent.
sa(t) = sb(t)
The statement can be rewritten as follows:
<Atcosα + xa, Atsinα + ya> = <Btcosβ + xb, Btsinβ + yb>
It follows that the x-components must equal each other, and the y-components must equal each other.
(Atcosα + xa) = (Btcosβ + xb) AND (Atsinα + ya) = (Btsinβ + yb)
For both equations, solve for β.
Atcosα + xa = Btcosβ + xb AND Atsinα + ya = Btsinβ + yb
Atcosα + xa)- xb = Btcosβ AND Atsinα + ya - yb = Btsinβ
cos-1((Atcosα + xa - xb)/(Bt)) = β AND sin-1((Atcosα + ya - yb)/(Bt)) = β
NOTE: The angle must be expressed in radians, not degrees.
The inverse trigonometric functions are only valid for a limited range of values. Arccosine has a domain of [-1, 1] and a range of [0, π] (half of the unit circle's worth of possible angles). Arcsine has a domain of [-1, 1] and a range of [-π/2, π/2] (half of the unit circle's worth of possible angles). In order to avoid errors, the value t must come within a specified range. If t isn't within the range, the program would have to translate that as meaning it is physically impossible for the entities to simultaneously intersect without entity A changing velocity or entity B changing speed. Since the range of the arccosine function is [0, π], β must fall in the same range. 0 ≤ cos -1((Atcosα + x a - x b)/(Bt)) ≤ π After taking the cosine of all parts of the statement, the possible domain is found. -1 ≤ (Atcosα + x a - x b)/(Bt) &le 1 Multiply all parts of the statement by the denominator of the solution to cos(β). -Bt ≤ Atcosα + x a - x b ≤ Bt Subtract Atcosα from all parts of the statement. -Bt - Atcosα ≤ x a - x b ≤ Bt - Atcosα Factor out t from the parts of the statement that have t. Since this doesn't change the statement, there is no need to factor out t from all parts of the statement. The previous steps did change the statement, so there was a need to apply those steps to all parts of the statement. -t(B + Acosα) ≤ x a - x b ≤ -t(-B + Acosα) Rewrite the statement. -t(B + Acosα) ≤ x a - x bAND -t(-B + Acosα) ≥ x a - x bFor each statement, isolate t. Since you are knowingly dividing by a negative amount, remember to switch the relational operator. t ≥ -(x a - x b)/(B + Acosα) AND t ≤ -(x a - x b)/(-B + Acosα) Just for grins and insight, distribute the negative into the numerator of the right-hand side of each statement. t ≥ (x b - x a)/(B + Acosα) AND t ≤ (x b - x a)/(-B + Acosα) Following the same general work, the following can be shown. t ≥ (y b - y a)/(B + Asinα) AND t ≤ (y b - y a)/(-B + Asinα) NOTE: Regardless of anything here, t must always be greater than 0. If at any moment in the program an entity has to go backwards in time in order to simultaneously intersect with another entity, you're doing it wrong![spoiler=Appendix: Concerning the Constraint of Angles Under Review] In order to still be considered a function and not have individual x values with multiple y values, the inverse trigonometric functions are only defined for half of all available angles. The question then arises: how do I know when I want an angle within the range versus one outside of the range?You add the solution β by π. Another question arises: how do I know when and when not to add the angle by π?The solution is rather simple: determine the direction of the entity with constant velocity (i.e. α). If α is between 0 and π, β must be between 0 and π. If α is between π and 2π, then β must be between π and 2π and the "correctional" addition of π must be applied. If α is between -π/2 and π/2, β must be between -π/2 and π/2. If α is between π/2 and 3π/2, then β must be between π/2 and 3π/2 and the "correctional" addition of π must be applied. If necessary, values below 0 should be added by 2π and values above 2π should be subtracted by 2π in order to give a comprehensible range of 0 to 2π. [/spoiler]
|
|
|
Post by microfarad on May 3, 2010 1:14:22 GMT -5
I dunno what to tell ya Veers. You made a very handy formula for testing whether one point's Y component is greater than another's. It returns infinity if the second point is higher than the first. :D
Junebug is pretty much toast without this. Sorry guys...
|
|
|
Post by ownedbyglove on May 3, 2010 17:49:31 GMT -5
MAn, It's only a minor part! And we don't need a computer program.
|
|
|
Post by General Veers on May 3, 2010 18:09:00 GMT -5
In order for the ships to intersect simultaneously, the displacement of entity B relative to its starting point must be equivalent to the displacement of entity A relative to entity B's starting point.
<Btcosβ, Btsinβ> = <Atcosα + xa - xb, Atsinα + ya - yb>
The magnitude of the vectors ergo should be equivalent.
((Btcosβ)2 + (Btsinβ)2)1/2 = ((Atcosα + xa - xb)2 + (Atsinα + ya - yb)2)1/2
(B2t2(cos2β + sin2β))1/2 = ((Atcosα + xa - xb)2 + (Atsinα + ya - yb)2)1/2
(B2t2)1/2 = ((Atcosα + xa - xb)2 + (Atsinα + ya - yb)2)1/2
B2t2 = (Atcosα + xa - xb)2 + (Atsinα + ya - yb)2
I have yet to finish...I hate typing out math statements in UBBC...
Feel free to solve on your own: this is now mere algebraic variable manipulation. I encourage you to solve this on your own and add to the work already here...
|
|
|
Post by microfarad on May 3, 2010 19:58:47 GMT -5
Veers, I appreciate your effort, but in all likely-hood, it will still fail. I have an alternative to this, which I just came up with. I shall begin on this new course of action...
|
|
|
Post by ownedbyglove on May 4, 2010 19:17:52 GMT -5
YAY! alternative course! alternative courses are nice.
|
|
|
Post by microfarad on May 5, 2010 0:15:47 GMT -5
Uuuuug. I'm getting slammed with homework. I'm delaying my projects a bit...
|
|