public const double Angle11_25 = 0.19634954;
public const double Angle15 = 0.261799;
public const double Angle22_5 = 0.3926991;
public const double Angle30 = 0.523599;
public const double Angle33_75 = 0.58904862;
public const double Angle45 = 0.785398;
public const double Angle56_25 = 0.785398;
public const double Angle60 = 1.0472;
public const double Angle67_5 = 1.178097;
public const double Angle75 = 1.309;
public const double Angle78_75 = 1.178097;
public const double Angle90 = 1.5708;
public const double Angle105 = 1.8326;
public const double Angle120 = 2.0944;
public const double Angle135 = 2.35619;
public const double Angle150 = 2.61799;
public const double Angle165 = 2.87979;
public const double Angle180 = 3.141592;
Vec2 CalibratedDirection(Vec2 dir)
{
var newLookDirX = 0;
if (dir.X >= MATH.Angle78_75) {
newLookDirX = 1;
} else if (dir.X >= MATH.Angle56_25) {
newLookDirX = MATH.Angle67_5;
} else if (dir.X >= MATH.Angle33_75) {
newLookDirX = MATH.Angle45;
} else if (dir.X >= MATH.Angle11_25) {
newLookDirX = MATH.Angle22_5;
} else if (dir.X >= -MATH.Angle11_25) {
newLookDirX = 0;
} else if (dir.X >= -MATH.Angle33_75) {
newLookDirX = -MATH.Angle22_5;
} else if (dir.X >= -MATH.Angle56_25) {
newLookDirX = -MATH.Angle45;
} else if (dir.X >= -MATH.Angle78_75) {
newLookDirX = -MATH.Angle67_5;
} else {
newLookDirX = -1;
}
var newLookDirY = 0;
if (dir.Y >= MATH.Angle78_75) {
newLookDirY = 1;
} else if (dir.Y >= MATH.Angle56_25) {
newLookDirY = MATH.Angle67_5;
} else if (dir.Y >= MATH.Angle33_75) {
newLookDirY = MATH.Angle45;
} else if (dir.Y >= MATH.Angle11_25) {
newLookDirY = MATH.Angle22_5;
} else if (dir.Y >= -MATH.Angle11_25) {
newLookDirY = 0;
} else if (dir.Y >= -MATH.Angle33_75) {
newLookDirY = -MATH.Angle22_5;
} else if (dir.Y >= -MATH.Angle56_25) {
newLookDirY = -MATH.Angle45;
} else if (dir.Y >= -MATH.Angle78_75) {
newLookDirY = -MATH.Angle67_5;
} else {
newLookDirY = -1;
}
return new Vec2(newLookDirX, newLookDirY);
}
반응형
'Programming > Blah Blah' 카테고리의 다른 글
리팩토링 (0) | 2019.10.03 |
---|---|
Gitea 사용해보기 (0) | 2019.08.14 |
데드 레커닝(Dead Reckoning) (0) | 2019.05.31 |
SharpNav (0) | 2018.09.01 |
비주얼 스튜디오 확장(vsix) (0) | 2018.05.05 |
.tt 확장자 예제 (0) | 2018.04.19 |
배치파일 (0) | 2018.04.10 |
신경망 첫걸음 (0) | 2018.03.25 |