From 2b68feee9be04a51facc56cbc0c1cb7616a26d6b Mon Sep 17 00:00:00 2001
From: tombrazier <68918209+tombrazier@users.noreply.github.com>
Date: Sun, 11 Jun 2023 19:36:45 +0100
Subject: Hamilton documentation and minor fixes (#1667)
* Minor corrections to alpha calculation and some comments to help it make sense
* Added some explanatory text to the hamilton filter dialog and changed the layout
---
filter-hamilton/ftnoir_filter_hamilton.cpp | 29 +-
filter-hamilton/ftnoir_filter_hamilton.h | 2 +-
filter-hamilton/ftnoir_hamilton_filtercontrols.ui | 1509 ++++++++++-----------
filter-hamilton/lang/nl_NL.ts | 26 +-
filter-hamilton/lang/ru_RU.ts | 26 +-
filter-hamilton/lang/stub.ts | 26 +-
filter-hamilton/lang/zh_CN.ts | 26 +-
7 files changed, 772 insertions(+), 872 deletions(-)
(limited to 'filter-hamilton')
diff --git a/filter-hamilton/ftnoir_filter_hamilton.cpp b/filter-hamilton/ftnoir_filter_hamilton.cpp
index be3faa7f..7bbc91de 100644
--- a/filter-hamilton/ftnoir_filter_hamilton.cpp
+++ b/filter-hamilton/ftnoir_filter_hamilton.cpp
@@ -34,11 +34,15 @@ void hamilton::filter(const double *input, double *output)
double dist = VectorDistance( &input[TX], pos_last);
double alpha = (dist - pos_deadzone) / (pos_max + pos_deadzone + EPSILON);
- alpha = fmin(alpha, 1.0);
- alpha = fmax(alpha, 0.0);
- alpha = pow (alpha, pos_pow);
- alpha = alpha * (dist - pos_deadzone) / (dist + EPSILON);
-
+ alpha = std::min(1.0, std::max(0.0, alpha));
+ if (alpha > 0.0)
+ alpha = pow(alpha, pos_pow);
+ // Scale alpha so that alpha * dist <= dist - pos_deadzone. This ensures that
+ // the center of the deadzone will never move closer to the input position than
+ // distance dist. And this ensures that the view never jumps ahead of head
+ // movements.
+ alpha *= (dist - pos_deadzone) / (dist + EPSILON);
+
pos_last = Lerp(pos_last, input, alpha);
output[TX] = pos_last.v[0];
@@ -48,11 +52,11 @@ void hamilton::filter(const double *input, double *output)
// zoom smoothing:
const double pow_zoom {s.kPowZoom};
const double max_z {s.kMaxZ};
- double rot_zoom = pow_zoom;
+ double rot_zoom = pow_zoom;
if (output[TZ] > 0) rot_zoom = 0;
- else rot_zoom *= -output[TZ] / (max_z + EPSILON);
- rot_zoom = fmin( rot_zoom, pow_zoom );
+ else rot_zoom *= -output[TZ] / (max_z + EPSILON);
+ rot_zoom = fmin( rot_zoom, pow_zoom );
// rotations:
const double rot_max {s.kMaxRot};
@@ -62,10 +66,11 @@ void hamilton::filter(const double *input, double *output)
double angle = AngleBetween(quat_input, quat_last);
alpha = (angle - rot_deadzone) / (rot_max + rot_deadzone + EPSILON);
- alpha = fmin(alpha, 1.0);
- alpha = fmax(alpha, 0.0);
- alpha = pow (alpha, rot_pow + rot_zoom);
- alpha = alpha * (angle - rot_deadzone) / (angle + EPSILON);
+ alpha = std::min(1.0, std::max(0.0, alpha));
+ if (alpha > 0.0)
+ alpha = pow(alpha, rot_pow + rot_zoom);
+ // see comment in earlier alpha calculation above
+ alpha *= (angle - rot_deadzone) / (angle + EPSILON);
quat_last = Slerp(quat_last, quat_input, alpha);
diff --git a/filter-hamilton/ftnoir_filter_hamilton.h b/filter-hamilton/ftnoir_filter_hamilton.h
index 0756c216..b724d973 100644
--- a/filter-hamilton/ftnoir_filter_hamilton.h
+++ b/filter-hamilton/ftnoir_filter_hamilton.h
@@ -43,7 +43,7 @@ public:
module_status initialize() override { return status_ok(); }
private:
tQuat quat_last;
- tVector pos_last;
+ tVector pos_last;
settings s;
bool first_run = true;
};
diff --git a/filter-hamilton/ftnoir_hamilton_filtercontrols.ui b/filter-hamilton/ftnoir_hamilton_filtercontrols.ui
index 71cdb6da..4c8b1536 100644
--- a/filter-hamilton/ftnoir_hamilton_filtercontrols.ui
+++ b/filter-hamilton/ftnoir_hamilton_filtercontrols.ui
@@ -13,7 +13,7 @@
0
0
514
- 491
+ 563
@@ -50,8 +50,8 @@
-
- -
+
+
-
@@ -65,322 +65,286 @@
150
-
-
- 8
- 50
- false
-
-
Rotations:
false
-
-
-
- 103
- 30
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- 0
-
-
- 250
-
-
- 1
-
-
- 50
-
-
- 100
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 50
-
-
-
-
-
- 7
- 30
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Max distance:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 424
- 30
- 61
- 20
-
-
-
-
- 45
- 0
-
-
-
-
-
-
- 10,00
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 7
- 110
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Dead Zone:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 103
- 110
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- 0
-
-
- 50
-
-
- 1
-
-
- 5
-
-
- 1
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 10
-
-
-
-
-
- 424
- 110
- 61
- 20
-
-
-
-
- 45
- 0
-
-
-
-
-
-
- 0,01
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 103
- 70
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- false
-
-
- 0
-
-
- 400
-
-
- 1
-
-
- 50
-
-
- 200
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 100
-
-
-
-
-
- 430
- 70
- 45
- 20
-
-
-
-
- 45
- 0
-
-
-
-
-
-
- 2,00
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 7
- 70
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Smoothing:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ false
+
+
+ 0
+
+
+ 400
+
+
+ 1
+
+
+ 50
+
+
+ 200
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 100
+
+
+
+ -
+
+
+
+ 45
+ 0
+
+
+
+
+
+
+ 2,00
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ 0
+
+
+ 50
+
+
+ 1
+
+
+ 5
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 10
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Smoothing power:
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Dead Zone:
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 45
+ 0
+
+
+
+
+
+
+ 0,01
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+ Max distance:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ 0
+
+
+ 250
+
+
+ 1
+
+
+ 50
+
+
+ 100
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 50
+
+
+
+ -
+
+
+
+ 45
+ 0
+
+
+
+
+
+
+ 10,00
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::LeftToRight
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+ true
+
- -
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ For both rotations and positions: No movement occurs within the dead zone. Smoothing scales down to minimum at max distance + 2 x dead zone.
+
+
+ true
+
+
+
+ -
@@ -397,300 +361,248 @@
Positions:
-
-
-
- 103
- 30
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- 0
-
-
- 200
-
-
- 1
-
-
- 50
-
-
- 100
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 50
-
-
-
-
-
- 7
- 70
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Smoothing:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 103
- 70
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- false
-
-
- 0
-
-
- 400
-
-
- 1
-
-
- 50
-
-
- 100
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 100
-
-
-
-
-
- 7
- 110
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Dead Zone:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 430
- 70
- 51
- 20
-
-
-
-
- 40
- 0
-
-
-
- 1,00
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 7
- 30
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Max distance:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 103
- 110
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- 0
-
-
- 50
-
-
- 1
-
-
- 10
-
-
- 2
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 10
-
-
-
-
-
- 420
- 30
- 71
- 20
-
-
-
-
- 45
- 0
-
-
-
- 10,00
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 420
- 110
- 71
- 20
-
-
-
-
- 45
- 0
-
-
-
- 0,02
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
+
+
-
+
+
+
+ 45
+ 0
+
+
+
+ 10,00
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Smoothing power:
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Max distance:
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ 0
+
+
+ 200
+
+
+ 1
+
+
+ 50
+
+
+ 100
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 50
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ false
+
+
+ 0
+
+
+ 400
+
+
+ 1
+
+
+ 50
+
+
+ 100
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 100
+
+
+
+ -
+
+
+
+ 40
+ 0
+
+
+
+ 1,00
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Dead Zone:
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ 0
+
+
+ 50
+
+
+ 1
+
+
+ 10
+
+
+ 2
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 10
+
+
+
+ -
+
+
+
+ 45
+ 0
+
+
+
+ 0,02
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
- -
+
-
@@ -707,227 +619,194 @@
Zoom smoothing:
-
-
-
- 434
- 30
- 45
- 20
-
-
-
-
- 45
- 0
-
-
-
- 2,00
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 103
- 30
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- false
-
-
- 0
-
-
- 400
-
-
- 1
-
-
- 50
-
-
- 200
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 100
-
-
-
-
-
- 7
- 30
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Smoothing :
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 103
- 60
- 311
- 20
-
-
-
-
- 0
- 0
-
-
-
- Qt::StrongFocus
-
-
- false
-
-
- 0
-
-
- 1000
-
-
- 1
-
-
- 50
-
-
- 150
-
-
- Qt::Horizontal
-
-
- QSlider::TicksBothSides
-
-
- 100
-
-
-
-
-
- 7
- 60
- 91
- 20
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Max Z:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
- 434
- 60
- 45
- 20
-
-
-
-
- 45
- 0
-
-
-
- 15,00
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Smoothing power:
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 45
+ 0
+
+
+
+ 2,00
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ false
+
+
+ 0
+
+
+ 400
+
+
+ 1
+
+
+ 50
+
+
+ 200
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 100
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ Max Z:
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::StrongFocus
+
+
+ false
+
+
+ 0
+
+
+ 1000
+
+
+ 1
+
+
+ 50
+
+
+ 150
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBothSides
+
+
+ 100
+
+
+
+ -
+
+
+
+ 45
+ 0
+
+
+
+ 15,00
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
- -
-
-
-
- 0
- 0
-
+
-
+
+
+ When you lean forward, zoom smoothing increases the smoothing power for rotations. Maximum additonal smoothing power occurs when you lean forward by a distance of Max Z.
-
- Qt::LeftToRight
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
+
true
+
+ dzRot
+ maxRot
+ powRot
+ dzDist
+ maxDist
+ powDist
+ maxZ
+ powZoom
+
diff --git a/filter-hamilton/lang/nl_NL.ts b/filter-hamilton/lang/nl_NL.ts
index b03e4c0b..1c720540 100644
--- a/filter-hamilton/lang/nl_NL.ts
+++ b/filter-hamilton/lang/nl_NL.ts
@@ -7,18 +7,10 @@
Rotations:
-
- Smoothing :
-
-
Positions:
-
- Max distance:
-
-
Zoom smoothing:
@@ -52,15 +44,27 @@
- Dead Zone:
+ 15,00
- Smoothing:
+ Smoothing power:
- 15,00
+ Dead Zone:
+
+
+
+ Max distance:
+
+
+
+ For both rotations and positions: No movement occurs within the dead zone. Smoothing scales down to minimum at max distance + 2 x dead zone.
+
+
+
+ When you lean forward, zoom smoothing increases the smoothing power for rotations. Maximum additonal smoothing power occurs when you lean forward by a distance of Max Z.
diff --git a/filter-hamilton/lang/ru_RU.ts b/filter-hamilton/lang/ru_RU.ts
index dfbb2268..f0681b21 100644
--- a/filter-hamilton/lang/ru_RU.ts
+++ b/filter-hamilton/lang/ru_RU.ts
@@ -7,18 +7,10 @@
Rotations:
-
- Smoothing :
-
-
Positions:
-
- Max distance:
-
-
Zoom smoothing:
@@ -52,15 +44,27 @@
- Dead Zone:
+ 15,00
- Smoothing:
+ Smoothing power:
- 15,00
+ Dead Zone:
+
+
+
+ Max distance:
+
+
+
+ For both rotations and positions: No movement occurs within the dead zone. Smoothing scales down to minimum at max distance + 2 x dead zone.
+
+
+
+ When you lean forward, zoom smoothing increases the smoothing power for rotations. Maximum additonal smoothing power occurs when you lean forward by a distance of Max Z.
diff --git a/filter-hamilton/lang/stub.ts b/filter-hamilton/lang/stub.ts
index a8af9f98..2b767312 100644
--- a/filter-hamilton/lang/stub.ts
+++ b/filter-hamilton/lang/stub.ts
@@ -7,18 +7,10 @@
Rotations:
-
- Smoothing :
-
-
Positions:
-
- Max distance:
-
-
Zoom smoothing:
@@ -52,15 +44,27 @@
- Dead Zone:
+ 15,00
- Smoothing:
+ Smoothing power:
- 15,00
+ Dead Zone:
+
+
+
+ Max distance:
+
+
+
+ For both rotations and positions: No movement occurs within the dead zone. Smoothing scales down to minimum at max distance + 2 x dead zone.
+
+
+
+ When you lean forward, zoom smoothing increases the smoothing power for rotations. Maximum additonal smoothing power occurs when you lean forward by a distance of Max Z.
diff --git a/filter-hamilton/lang/zh_CN.ts b/filter-hamilton/lang/zh_CN.ts
index 4fc4d812..222569e4 100644
--- a/filter-hamilton/lang/zh_CN.ts
+++ b/filter-hamilton/lang/zh_CN.ts
@@ -7,18 +7,10 @@
Rotations:
-
- Smoothing :
-
-
Positions:
-
- Max distance:
-
-
Zoom smoothing:
@@ -52,15 +44,27 @@
- Dead Zone:
+ 15,00
- Smoothing:
+ Smoothing power:
- 15,00
+ Dead Zone:
+
+
+
+ Max distance:
+
+
+
+ For both rotations and positions: No movement occurs within the dead zone. Smoothing scales down to minimum at max distance + 2 x dead zone.
+
+
+
+ When you lean forward, zoom smoothing increases the smoothing power for rotations. Maximum additonal smoothing power occurs when you lean forward by a distance of Max Z.
--
cgit v1.2.3