Hi,
Im using this to calculate angle between two vectors f@angle = degrees( acos (dot(normalize(@dir), normalize(@c)) )); But this gives me just positive values. my @c is {1,0,0} if @dir is {0.5, -0.5,0} I want that it returns a negative angle and {0.5, 0.5,0} would return a positive value. How to do this?
Thx
Mika
Negative angles when caulcate angle between two vectors
1305 2 0- mihatsu
- Member
- 76 posts
- Joined: Aug. 2018
- Offline
- Aizatulin
- Member
- 479 posts
- Joined: July 2005
- Offline
Hi,
you can use plane for example defined by an up vector ((0,1,0) or something) and @c (plane noraml ~ normalized cross product of
both). This plane can be used to detect, if the @dir vector is on the positive/negative side (using the dot product of @dir and the
plane normal). The result depends on the plane itself, if you invert the normal for example the positive angles will become negative
and vice versa.
you can use plane for example defined by an up vector ((0,1,0) or something) and @c (plane noraml ~ normalized cross product of
both). This plane can be used to detect, if the @dir vector is on the positive/negative side (using the dot product of @dir and the
plane normal). The result depends on the plane itself, if you invert the normal for example the positive angles will become negative
and vice versa.
Edited by Aizatulin - May 3, 2020 04:32:25
- mihatsu
- Member
- 76 posts
- Joined: Aug. 2018
- Offline
Aizatulin
Hi,
you can use plane for example defined by an up vector ((0,1,0) or something) and @c (plane noraml ~ normalized cross product of
both). This plane can be used to detect, if the @dir vector is on the positive/negative side (using the dot product of @dir and the
plane normal). The result depends on the plane itself, if you invert the normal for example the positive angles will become negative
and vice versa.
This worked! Thanks!
-
- Quick Links