Clang-format tests, examples, libraries, benchmarks, etc.

This commit is contained in:
Antonio Sánchez
2023-12-05 21:22:55 +00:00
committed by Rasmus Munk Larsen
parent 3252ecc7a4
commit 46e9cdb7fe
876 changed files with 33453 additions and 37795 deletions

View File

@@ -12,21 +12,17 @@
using namespace Eigen;
void Trackball::track(const Vector2i& point2D)
{
if (mpCamera==0)
return;
void Trackball::track(const Vector2i& point2D) {
if (mpCamera == 0) return;
Vector3f newPoint3D;
bool newPointOk = mapToSphere(point2D, newPoint3D);
if (mLastPointOk && newPointOk)
{
if (mLastPointOk && newPointOk) {
Vector3f axis = mLastPoint3D.cross(newPoint3D).normalized();
float cos_angle = mLastPoint3D.dot(newPoint3D);
if ( std::abs(cos_angle) < 1.0 )
{
if (std::abs(cos_angle) < 1.0) {
float angle = 2. * acos(cos_angle);
if (mMode==Around)
if (mMode == Around)
mpCamera->rotateAroundTarget(Quaternionf(AngleAxisf(angle, axis)));
else
mpCamera->localRotate(Quaternionf(AngleAxisf(-angle, axis)));
@@ -37,23 +33,19 @@ void Trackball::track(const Vector2i& point2D)
mLastPointOk = newPointOk;
}
bool Trackball::mapToSphere(const Vector2i& p2, Vector3f& v3)
{
if ((p2.x() >= 0) && (p2.x() <= int(mpCamera->vpWidth())) &&
(p2.y() >= 0) && (p2.y() <= int(mpCamera->vpHeight())) )
{
double x = (double)(p2.x() - 0.5*mpCamera->vpWidth()) / (double)mpCamera->vpWidth();
double y = (double)(0.5*mpCamera->vpHeight() - p2.y()) / (double)mpCamera->vpHeight();
double sinx = sin(M_PI * x * 0.5);
double siny = sin(M_PI * y * 0.5);
double sinx2siny2 = sinx * sinx + siny * siny;
bool Trackball::mapToSphere(const Vector2i& p2, Vector3f& v3) {
if ((p2.x() >= 0) && (p2.x() <= int(mpCamera->vpWidth())) && (p2.y() >= 0) && (p2.y() <= int(mpCamera->vpHeight()))) {
double x = (double)(p2.x() - 0.5 * mpCamera->vpWidth()) / (double)mpCamera->vpWidth();
double y = (double)(0.5 * mpCamera->vpHeight() - p2.y()) / (double)mpCamera->vpHeight();
double sinx = sin(M_PI * x * 0.5);
double siny = sin(M_PI * y * 0.5);
double sinx2siny2 = sinx * sinx + siny * siny;
v3.x() = sinx;
v3.y() = siny;
v3.z() = sinx2siny2 < 1.0 ? sqrt(1.0 - sinx2siny2) : 0.0;
return true;
}
else
} else
return false;
}