-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtil.cs
40 lines (34 loc) · 983 Bytes
/
Util.cs
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
using System;
using System.Numerics;
class Util
{
public static Vector3 RotatePosition(Vector3 pos, Vector3 rot)
{
float x = pos.X;
float y = pos.Y;
float z = pos.Z;
Vector3 result = new Vector3(pos.X, pos.Y, pos.Z);
if (rot.Z != 0)
{
float cosZ = (float)Math.Cos(rot.Z);
float sinZ = (float)Math.Sin(rot.Z);
result.X = x * cosZ - y * sinZ;
result.Y = y * cosZ + x * sinZ;
}
if (rot.X != 0)
{
float cosX = (float)Math.Cos(rot.X);
float sinX = (float)Math.Sin(rot.X);
result.Y = y * cosX - z * sinX;
result.Z = z * cosX + y * sinX;
}
if (rot.Y != 0)
{
float cosY = (float)Math.Cos(rot.Y);
float sinY = (float)Math.Sin(rot.Y);
result.Z = z * cosY - x * sinY;
result.X = x * cosY + z * sinY;
}
return result;
}
}