Page 1 sur 1

angle of a vector

Publié : sam. sept. 27, 2025 4:14 am
par compsystems
Hi, the command ARG() says

Angle of a vector
The arg command finds the angle of a complex number (the argument) or the angle of a vector defined by two points.

arg takes v, a number or a vector defined by two points.
arg(v) returns the argument of v if v is a complex number or the angle between the positive x direction and v if v is a vector.
Example
arg(1+i) -> pi/4


How do you get the angle of a vector?

I wish to obtain
arg([3,4]) -> atan(4/3)

Re: angle of a vector

Publié : sam. sept. 27, 2025 10:56 am
par parisse
I'm afraid you are confused, arg does not take a vector or 2 points as argument, it expects a complex number.

Re: angle of a vector

Publié : sam. sept. 27, 2025 7:18 pm
par XcasEngGuy
Try this:
test.jpg
test.jpg (28.78 Kio) Consulté 1139 fois

Re: angle of a vector

Publié : mar. sept. 30, 2025 6:33 pm
par compsystems
Hello
Please expand the functionality to accept a vector.

Re: angle of a vector

Publié : mar. sept. 30, 2025 8:01 pm
par XcasEngGuy
Try:

Code : Tout sélectionner

vec_arg(vec):={
  var cmplx;
  cmplx:=vec[0]+i*vec[1];
  return evalf(arg(cmplx));
}:;