Comments and answers for "Math Genius NEEDED! Algorithm problem with parabola"
http://answers.unity.com/questions/1382704/math-genius-needed-algorithm-problem-with-parabola.html
The latest comments and answers for the question "Math Genius NEEDED! Algorithm problem with parabola"Comment by Yoshinator2 on Yoshinator2's comment
http://answers.unity.com/comments/1383444/view.html
if you wouldnt mind taking a crack at my next problem..
http://answers.unity3d.com/questions/1383443/local-quaternion-vs-global-quaternion-ive-been-wor.htmlMon, 24 Jul 2017 03:52:17 GMTYoshinator2Comment by Yoshinator2 on Yoshinator2's comment
http://answers.unity.com/comments/1383071/view.html
You are amazing. Thank you SO much!!!!!!!!!!!!!!Sun, 23 Jul 2017 05:23:49 GMTYoshinator2Comment by Bunny83 on Bunny83's comment
http://answers.unity.com/comments/1383035/view.html
ps: decompose means if you have a power of "3.2" it would have to split that power into "3" and "0.2". It can then do a simple integer power with the 3 and in addition calculate the 5th root of the base ((1 / 0.2) --> 5th root). As you might know multiplying two numbers with the same base but different exponent is the same as when you just add the two exponents together. So `(B^x * B^y)` is the same as `B^(x+y)`.Sun, 23 Jul 2017 02:53:20 GMTBunny83Comment by Bunny83 on Bunny83's comment
http://answers.unity.com/comments/1383034/view.html
Yes, about a factor of "10". First of all $$anonymous$$athf.Pow is (like almost all methods of $$anonymous$$athf) just a wrapper for System.$$anonymous$$ath.Pow just casted to float. All System.$$anonymous$$ath methods work with double. It's literally defined as:
public static float Pow(float f, float p)
{
return (float)$$anonymous$$ath.Pow((double)f, (double)p);
}
Though the slight casting overhad is not the worst. A simple native floating point multiplication will be carried out directly inline by FPU opcodes while Pow is an actual method call. The main problem is that Pow does work with non-integer powers as well. That means the method has to decompose the power into an integer part and a fractional part.
I ran a quick test and did 1$$anonymous$$ Pow with "2" as power in a loop and it took 733k ticks on my machine. By doing a simple "manual square" (i.e. "x * x") it took only 66k ticks. It roughly translated to about 70 ms vs 6 ms.Sun, 23 Jul 2017 02:42:19 GMTBunny83Comment by ShadyProductions on ShadyProductions's answer
http://answers.unity.com/comments/1382988/view.html
Is there a disadvantage for using `$$anonymous$$athf.Pow(v_, 2)` ins$$anonymous$$d of `(v_ * v_)` for a simple power?Sat, 22 Jul 2017 23:55:11 GMTShadyProductionsAnswer by Bunny83
http://answers.unity.com/answers/1382942/view.html
Well first of all "g" should be the value of the acceleration. This should be positive. There is no direction information in a single value. You seem to use the y component of the Physics gravity vector which is usually negative.
Next thing is the formula you use only works when both your firePoint as well as your target are on the exact same height. Also keep in mind when you rely on Unity's physics engine for the actual simulation that this assumes no drag at all.
You also need to check if the term inside ASin is not lower than "-1" or greater than "1", In that case the target can't be reached at all. Also ASin would return a NaN in that case.
If the height of the two points can be different you have to use [this one][1] instead. Of course here a similar check has to be done. You can only reach the target when the root has a real value (i.e. the value inside the root has to be 0 or positive). If the root is a complex root the target can't be reached,
Finally what do you actually pass to your "Fire" method? Currently you pass the distance between you and the target. Shouldn't you somehow pass the angle?
ps: Never use "pow" for simple powers. This `(Mathf.Pow(v_, 2))` should be simply
`(v_ * v_)`
[1]: https://en.wikipedia.org/wiki/Trajectory_of_a_projectile#Angle_.7F.27.22.60UNIQ--postMath-00000010-QINU.60.22.27.7F_required_to_hit_coordinate_.28x.2Cy.29Sat, 22 Jul 2017 20:54:05 GMTBunny83Comment by Bobtown
http://answers.unity.com/comments/1382928/view.html
Your angle seems to be calculated correctly, unless the firePoint and target are in different elevations (different z values). The formula you use is correct, but only for objects of the same elevation. $$anonymous$$aybe the problem is with your obj.Fire function?Sat, 22 Jul 2017 20:12:14 GMTBobtown