Hi!
I wanted to make a patch of grass where all the grass blades faces away from the origin. All my points are on the X and Z axis (Y is always zero). Since I have my @P.x and @P.y, I though I could find the radian by using atan. Later, I could use that radian in a quaternion.
The results works only in the -X but not in the +X. Here's my vex:
vector up = set(0,1,0);
float radians = atan(@P.x/@P.z);
@orient = quaternion(radians, up);
I don't remember much of trigonometry so I probably used it the wrong way…
Any help is appreciated!
-Olivier
finding angle with trigonometry: help!
1812 2 1- olivierth
- Member
- 1010 posts
- Joined: April 2017
- Offline
- olivierth
- Member
- 1010 posts
- Joined: April 2017
- Offline
Ahh!! FIXED!
Instead of using atan function, I used atan2 function.
vector up = set(0,1,0);
float radians = atan2(@P.x, @P.z);
@orient = quaternion(radians, up);
yeah! (*self high-five)
-Olivier
Instead of using atan function, I used atan2 function.
vector up = set(0,1,0);
float radians = atan2(@P.x, @P.z);
@orient = quaternion(radians, up);
yeah! (*self high-five)
-Olivier
- Rebus B
- Member
- 80 posts
- Joined: June 2013
- Offline
-
- Quick Links