초기커밋
This commit is contained in:
79
ServerCore/Math/TransformHelper.cs
Normal file
79
ServerCore/Math/TransformHelper.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
namespace ServerCore;
|
||||
|
||||
public class TransformHelper
|
||||
{
|
||||
public static Position rotateX(Position pos, Rotation rot)
|
||||
{
|
||||
double radian = (Math.PI * rot.Roll) / 180.0f;
|
||||
var cosValue = Math.Cos(radian);
|
||||
var sinValue = Math.Sin(radian);
|
||||
|
||||
double y = (pos.Y * cosValue) + (pos.Z * -sinValue);
|
||||
double z = (pos.Y * sinValue) + (pos.Z * cosValue);
|
||||
|
||||
Position retValue = new Position
|
||||
{
|
||||
X = pos.X,
|
||||
Y = y,
|
||||
Z = z,
|
||||
};
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public static Position rotateY(Position pos, Rotation rot)
|
||||
{
|
||||
double radian = (Math.PI * rot.Pitch) / 180.0f;
|
||||
var cosValue = Math.Cos(radian);
|
||||
var sinValue = Math.Sin(radian);
|
||||
|
||||
double x = (pos.X * cosValue) + (pos.Z * -sinValue);
|
||||
double z = (pos.X * sinValue) + (pos.Z * cosValue);
|
||||
|
||||
Position retValue = new Position
|
||||
{
|
||||
X = x,
|
||||
Y = pos.Y,
|
||||
Z = z,
|
||||
};
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public static Position rotateZ(Position pos, Rotation rot)
|
||||
{
|
||||
double radian = (Math.PI * rot.Yaw) / 180.0f;
|
||||
var cosValue = Math.Cos(radian);
|
||||
var sinValue = Math.Sin(radian);
|
||||
|
||||
double x = (pos.X * cosValue) + (pos.Y * -sinValue);
|
||||
double y = (pos.X * sinValue) + (pos.Y * cosValue);
|
||||
|
||||
Position retValue = new Position
|
||||
{
|
||||
X = x,
|
||||
Y = y,
|
||||
Z = pos.Z,
|
||||
};
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
public static Position rotate(Position pos, Rotation rot)
|
||||
{
|
||||
Position tempPos;
|
||||
tempPos = rotateY(pos, rot);
|
||||
tempPos = rotateZ(tempPos, rot);
|
||||
tempPos = rotateX(tempPos, rot);
|
||||
|
||||
return tempPos;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user