angle of a vector

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 613
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

angle of a vector

Message par compsystems » sam. sept. 27, 2025 4:14 am

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)

parisse
Messages : 5916
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: angle of a vector

Message par parisse » sam. sept. 27, 2025 10:56 am

I'm afraid you are confused, arg does not take a vector or 2 points as argument, it expects a complex number.

XcasEngGuy
Messages : 166
Inscription : mer. janv. 13, 2010 3:20 pm

Re: angle of a vector

Message par XcasEngGuy » sam. sept. 27, 2025 7:18 pm

Try this:
test.jpg
test.jpg (28.78 Kio) Consulté 1138 fois

compsystems
Messages : 613
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: angle of a vector

Message par compsystems » mar. sept. 30, 2025 6:33 pm

Hello
Please expand the functionality to accept a vector.

XcasEngGuy
Messages : 166
Inscription : mer. janv. 13, 2010 3:20 pm

Re: angle of a vector

Message par XcasEngGuy » mar. sept. 30, 2025 8:01 pm

Try:

Code : Tout sélectionner

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

Répondre