-3

I was reading the the answers to the question about finding the angle between 2 vectors in 3D space. Signed angle between two 3D vectors with same origin within the same plane. The answer is shown here:

atan2((Vb x Va) . Vn, Va . Vb)

is exactly what I need, but I don't understand what the commas operator is. I know that the exes and dots are cross products and dot products respectively. I don't think the commas are inner products (same thing as dot products)? Perhaps, it is a syntax of a programming language?

Astronomer
  • 119
  • 4
  • 7
    There is no comma operator there, it's just a function that takes two arguments. – harold Aug 20 '17 at 03:00
  • It's arc tangent of y/x using the signs of arguments to determine the correct quadrant, hence two parameters. – Robinson Aug 20 '17 at 03:01
  • Unlike arctan, [`atan2`](https://en.wikipedia.org/wiki/Atan2) takes two arguments. – user2357112 Aug 20 '17 at 03:02
  • Does that means that this equation is limited to angle on the x,y-plane? – Astronomer Aug 20 '17 at 03:03
  • The "code" that you posted is most certainly not valid C++ code. – Silvio Mayolo Aug 20 '17 at 03:04
  • FWIW, that is not compilable code. You cannot overload the dot (`.`) operator to compute the dot product of two geometric vectors. That line is a mix of C++ function `atan2` and mathematical notations that are not valid C++ syntax. – R Sahu Aug 20 '17 at 03:05
  • I'm mostly just interested in the math behind the code. Is it possible to return a signed angle, given two vectors using something similar to the above form? – Astronomer Aug 20 '17 at 03:07
  • The question the snippet was originally posted to wasn't a C++ question, though, and the answer never claimed to have anything to do with C++, so it's no surprise it's not compilable C++. (atan2 exists in a lot of languages.) – user2357112 Aug 20 '17 at 03:08
  • `arctan()` is a function, not an operator. It's no good posting meaningless code and then asking what it means. – user207421 Aug 20 '17 at 03:08
  • Why is *this* question tagged C++, anyway? – user2357112 Aug 20 '17 at 03:09
  • That's not a meaningless code. I found it elsewhere as the most upvoted answer, and posted here to inquire about the answer. I don't see why all the flaming. – Astronomer Aug 20 '17 at 03:11
  • It is meaningless code **if you tag it as C++**. From what I can tell from the context where you got it, it is either Matlab code or pseudo-code. So tagging it as "c++" is actually wasting the time of a bunch of C++ experts ... and **deserving** of flamage for that reason. – Stephen C Aug 20 '17 at 03:21
  • That question must have taken 2 seconds to read. If you cannot afford 2 seconds of your time, why are you on stackoverflow community trying to answer questions? The whole point of this community is to share answers and help each other. Also, I AM working on c++, hence the tag. – Astronomer Aug 20 '17 at 16:34
  • *"The whole point of this community is to share answers and help each other."* - Which does not excuse people from using their common sense when asking questions. The fact that people are generally here to be helpful does not mean that you can *abuse* their good will by wasting their time. And it doesn't give you any standing to complain when they are annoyed by that. – Stephen C Aug 21 '17 at 23:21
  • *"Also, I AM working on c++"* - That is irrelevant. The tags are supposed to be used to indicate the topic of the question itself. And in this case, 1) the code is clearly not C++, and the question is clearly not about C++. Basically, you used the tag for no reason that stands up to logical scrutiny - which respect to how tags are designed to be used. Anyhow, you said "I don't see why all the flaming" ... and this is the explanation. – Stephen C Aug 21 '17 at 23:29

1 Answers1

0

The language is (I think1) Matlab, and the comma is actually an argument separator (NOT an operator2) in a method call.


1 - This is consistent with the context where you found this expression, though I suspect that the author was actually using Matlab syntax as a way of expressing a mathematical concept.

2 - According to https://au.mathworks.com/help/matlab/matlab_prog/matlab-operators-and-special-characters.html

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216