Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
acos
  • Loading branch information
Sergeanur committed Jan 29, 2020
1 parent daf1fdf commit 81de0e0cbd7d3834c71282348ce61b69474a01e8
Showing with 5 additions and 5 deletions.
  1. +1 −1 src/core/FileLoader.cpp
  2. +4 −4 src/peds/PedIK.cpp
@@ -679,7 +679,7 @@ CFileLoader::LoadMLOInstance(int id, const char *line)
&scale.x, &scale.y, &scale.z,
&rot.x, &rot.y, &rot.z,
&angle);
float rad = 2.0f * (PI / 2.0f - Atan2(angle, Sqrt(1.0f - SQR(angle))));
float rad = Acos(angle) * 2.0f;
CInstance *inst = CModelInfo::GetMloInstanceStore().alloc();
minfo->lastInstance++;

@@ -344,23 +344,23 @@ void
CPedIK::ExtractYawAndPitchWorld(RwMatrixTag *mat, float *yaw, float *pitch)
{
float f = clamp(DotProduct(mat->up, CVector(0.0f, 1.0f, 0.0f)), -1.0f, 1.0f);
*yaw = HALFPI - Atan2(f, Sqrt(1.0f - f * f));
*yaw = Acos(f);
if (mat->up.x > 0.0f) *yaw = -*yaw;

f = clamp(DotProduct(mat->right, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f);
*pitch = HALFPI - Atan2(f, Sqrt(1.0f - f * f));
*pitch = Acos(f);
if (mat->up.z > 0.0f) *pitch = -*pitch;
}

void
CPedIK::ExtractYawAndPitchLocal(RwMatrixTag *mat, float *yaw, float *pitch)
{
float f = clamp(DotProduct(mat->at, CVector(0.0f, 0.0f, 1.0f)), -1.0f, 1.0f);
*yaw = HALFPI - Atan2(f, Sqrt(1.0f - f * f));
*yaw = Acos(f);
if (mat->at.y > 0.0f) *yaw = -*yaw;

f = clamp(DotProduct(mat->right, CVector(1.0f, 0.0f, 0.0f)), -1.0f, 1.0f);
*pitch = HALFPI - Atan2(f, Sqrt(1.0f - f * f));
*pitch = Acos(f);
if (mat->up.x > 0.0f) *pitch = -*pitch;
}

0 comments on commit 81de0e0

Please sign in to comment.