I have kind of a meta question about trigonometry!
Am I right in assuming that the following calculation/formula gives me the angle alpha between a two-dimensional vector and the x-axis of a plane (i.e. xy-plane)?
For the y-coordinate of the vector being bigger than 0:
alpha = acos(vector x / vector length)
For the y-coordinate being smaller or equal to 0:
alpha = 2 x Pi - acos(vector x / vector length)
Furthermore, how would I go about introducing 3D space into this? I mean calculating the angle for three-dimensional vectors? This would only be possible in the local plane of the vector and the x-axis, wouldn’t it?
Hello matie!
It’s always useful to remember the unit circle from high-school:
each 2d vector is analyzed into x and y axes.
for any given angle α,
the sin(α) =y
cos(α)=χ
tan(α)=y/x
reversing this gives us:
asin(y) = α
acos(x) = α
atan(y/x) = α
without needing to worry about negative or positive values
as for the 3D space, it depends what you want to calculate and to what ends.
You can get the 3 components of your 3d vector or consider a plane it resides in as your axes and treat it as a 2d vector.
If you want to have some freedom in 3d space though, as @fertig said, you should be able to use dot product and cross product with ease.
the first equation is right because vector x/ vector length = cos(α)
the second equation is also right but just coincidentally: explementary angles have same x values
(if you were to analyze the sine it would be:
α = 2*π - asin(-vector y/ vector length)