-
Notifications
You must be signed in to change notification settings - Fork 3
/
MathFunctions.h
46 lines (36 loc) · 1.57 KB
/
MathFunctions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include "Vector.h"
#include "SDK.h"
#include <stdint.h>
#define PI 3.14159265358979323846f
#define DEG2RAD( x ) ( ( float )( x ) * ( float )( ( float )( PI ) / 180.0f ) )
#define RAD2DEG( x ) ( ( float )( x ) * ( float )( 180.0f / ( float )( PI ) ) )
#define RADPI 57.295779513082f
#define rad(a) a * 0.01745329251
void AngleVectors(const Vector &angles, Vector *forward);
void VectorTransform(const Vector in1, float in2[3][4], Vector &out);
void SinCos(float a, float* s, float*c);
void VectorAngles(Vector forward, Vector &angles);
void AngleVectors(const Vector &angles, Vector *forward, Vector *right, Vector *up);
void Normalize(Vector &vIn, Vector &vOut);
void CalcAngle(Vector src, Vector dst, Vector &angles);
bool IsVisible(IClientEntity* pLocal, IClientEntity* pEntity, int BoneID);
void CalcAngleYawOnly(Vector src, Vector dst, Vector &angles);
void NormalizeVector(Vector& vec);
inline Vector angle_vector(Vector meme)
{
auto sy = sin(meme.y / 180.f * static_cast<float>(PI));
auto cy = cos(meme.y / 180.f * static_cast<float>(PI));
auto sp = sin(meme.x / 180.f * static_cast<float>(PI));
auto cp = cos(meme.x / 180.f* static_cast<float>(PI));
return Vector(cp*cy, cp*sy, -sp);
}
inline float distance_point_to_line(Vector Point, Vector LineOrigin, Vector Dir)
{
auto PointDir = Point - LineOrigin;
auto TempOffset = PointDir.Dot(Dir) / (Dir.x*Dir.x + Dir.y*Dir.y + Dir.z*Dir.z);
if (TempOffset < 0.000001f)
return FLT_MAX;
auto PerpendicularPoint = LineOrigin + (Dir * TempOffset);
return (Point - PerpendicularPoint).Length();
}