Comments and answers for "Is Vector3.Dot faster than Vector3.Angle?"
http://answers.unity.com/questions/1409137/is-vector3dot-faster-than-vector3angle.html
The latest comments and answers for the question "Is Vector3.Dot faster than Vector3.Angle?"Comment by orionsyndrome
http://answers.unity.com/comments/1566454/view.html
Dot products or "scalar vector products" are used for a myriad of things: vector projections, interceptions, intersections, fast motion or proximity detectors, slope detectors, fast calculations of all sorts you'd otherwise do with trig. So yes, there is something more clever that you can do with dot products, but the topic is so vast I couldn't cover it in this comment alone. Cross products, or true vector products, are as much as important, and the two (along with the addition and subtraction) form the basis for the vector math.
If it helps, one could divide general geometry in three areas, and I'm talking exclusively from the game engineering perspective: 1) trigonometry, 2) vectors, 3) analytic geometry. Trigonometry, even really basic one, is usually quite enough when working with 2D, but mastering all of the fields can turn you into a beast in 3D.
Vectors are essentially very fast, computation-wise, and elegant enough if you know what you're doing. In my experience, they are also the easiest to visualize, however you have to keep in mind that a single Vector3 can represent quite a few different things, a position, a direction, or a difference (or unpacked distance). I also use barycentric coordinates, which belong to affine geometry and you absolutely need dot products to even begin thinking stepping outside of the XYZ coordinate system.
For example, this is how you might compute an angle (in radians) between two given radial vectors (the assumption is that they share the same origin)
float calcAngle(Vector3 a, Vector3 b) {
return Mathf.Atan2(Vector3.Cross(a, b).magnitude, Vector3.Dot(a, b));
}
Because arc length = radius * angle (s = r x theta) which is a definition of a radian.
The method above returns the unit arc length when the vectors are normalized.
For the general arc length, multiply the result by radius.Sun, 28 Oct 2018 03:51:35 GMTorionsyndromeComment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/1498793/view.html
The problem, if you want the angle, is there are two more steps. You have to normalize the vectors or know they already are. Then you have to think in reverse cosin. Ex: dot>0.707 instead of angle<45.
When you ask if one thing is faster than the other, they have to be doing the same thing, and these aren't.Wed, 25 Apr 2018 22:32:30 GMTOwen-ReynoldsAnswer by balfire
http://answers.unity.com/answers/1498725/view.html
No. Unity does not use the cosine to calculate dot product. If you look around the internet you can find decompiled unity source files. There you can see that dot product is calculated as follows: dot(a,b) = a.x*b.x + a.y*b.y + a.z*b.z.
I myself use Dot when i need to find the cosine between two vectors. In fact, Angle is defined through the use of Dot.Wed, 25 Apr 2018 19:32:57 GMTbalfireComment by Owen-Reynolds
http://answers.unity.com/comments/1409186/view.html
The dot product is a standard mathematical thing. Formulas use it, people who know 3D trig use it. Math textbooks have the best explanations. But it seems like you don't have a strong trigonometry background (many very good game developers don't) and are confusing yourself.
If you really want to learn more math, you could review how cosine and arc-cosine work. Or just do what everyone else who hates trig does and use Angle.Tue, 19 Sep 2017 12:59:28 GMTOwen-ReynoldsComment by hexagonius
http://answers.unity.com/comments/1409150/view.html
Don't know about the performance. But what you're describing about the dot product is just the case for two normalized vectors. If, however you match a vector against a normalized one, you get the amount of the first vector in the direction of the normalized one.
Like the amount of drift when using the dot product with the velocity and any side direction vector of the car.Tue, 19 Sep 2017 11:25:33 GMThexagonius