Does anybody know how Garry's Angle.Forward/Angle.Up/Angle.Right and Vector.GetAngle functions work?
I need this for my game I'm working on in directx.
This isn't giving accurate results.
[code]
Pitch *= 1.0 / 180.0 * Math.PI; //Convert to radians
Yaw *= 1.0 / 180.0 * Math.PI;
Roll *= 1.0 / 180.0 * Math.PI;
double X = Math.Cos(Pitch) * Math.Sin(Yaw);
double Y = Math.Sin(Yaw) * Math.Cos(Pitch);
double Z = -1 * Math.Sin(Pitch);
[/code]
This =
(new Angle3(2,3,4)).Forward();
0.0523 0.05230 -0.0348
(new Angle3(80,30,200)).Forward();
0.0868 0.0868 -0.9848
(new Angle3(100,5,200)).Forward();
-0.0151 -0.0151 -0.9848
Garrysmod =
> print(Angle(2,3,4):Forward())...
0.9980 0.0523 -0.0349
> print(Angle(80,30,200):Forward())...
0.1504 0.0868 -0.9848
> print(Angle(100,5,200):Forward())...
-0.1730 -0.0151 -0.9848
Or is it Quaternions I need to look into?
[QUOTE=thegrb93;17126866]Does anybody know how Garry's Angle.Forward/Angle.Up/Angle.Right and Vector.GetAngle functions work?
I need this for my game I'm working on in directx.
This isn't giving accurate results.
[code]
Pitch *= 1.0 / 180.0 * Math.PI; //Convert to radians
Yaw *= 1.0 / 180.0 * Math.PI;
Roll *= 1.0 / 180.0 * Math.PI;
double X = Math.Cos(Pitch) * Math.Sin(Yaw);
double Y = Math.Sin(Yaw) * Math.Cos(Pitch);
double Z = -1 * Math.Sin(Pitch);
[/code]
This =
(new Angle3(2,3,4)).Forward();
0.0523 0.05230 -0.0348
(new Angle3(80,30,200)).Forward();
0.0868 0.0868 -0.9848
(new Angle3(100,5,200)).Forward();
-0.0151 -0.0151 -0.9848
Garrysmod =
> print(Angle(2,3,4):Forward())...
0.9980 0.0523 -0.0349
> print(Angle(80,30,200):Forward())...
0.1504 0.0868 -0.9848
> print(Angle(100,5,200):Forward())...
-0.1730 -0.0151 -0.9848
Or is it Quaternions I need to look into?[/QUOTE]
I'd look into quaternions since they are a point in space which face towards a specific direction, and that sounds like what you are trying to do. :)
You might be able to find them in the source code for a mod.
I think I found it in mathlib_base.cpp
void AngleVectors()
I didn't think valve had already written it. thanks
Sorry, you need to Log In to post a reply to this thread.