1 #ifndef INCLUDE_AL_CONTROL_NAV_HPP
2 #define INCLUDE_AL_CONTROL_NAV_HPP
50 #include "al/io/al_Window.hpp"
51 #include "al/spatial/al_Pose.hpp"
71 double smooth()
const {
return mSmooth; }
85 double velScale()
const {
return mVelScale; }
93 Nav &view(
double azimuth,
double elevation,
double bank);
108 void move(
double dr,
double du,
double df) {
113 template <
class T>
void move(
const Vec<3, T> &dp) {
114 move(dp[0], dp[1], dp[2]);
118 void moveR(
double v) { mMove0[0] = v; }
121 void moveU(
double v) { mMove0[1] = v; }
124 void moveF(
double v) { mMove0[2] = v; }
126 Vec3d &move() {
return mMove0; }
129 void nudge(
double dr,
double du,
double df) {
135 nudge(dp[0], dp[1], dp[2]);
138 void nudgeR(
double amount) { mNudge[0] += amount; }
139 void nudgeU(
double amount) { mNudge[1] += amount; }
140 void nudgeF(
double amount) { mNudge[2] += amount; }
144 void spin(
double da,
double de,
double db) {
150 spin(daeb[0], daeb[1], daeb[2]);
157 void spinR(
double v) { mSpin0[1] = v; }
160 void spinU(
double v) { mSpin0[0] = v; }
163 void spinF(
double v) { mSpin0[2] = v; }
169 void turn(
double az,
double el,
double ba) {
175 turn(daeb[0], daeb[1], daeb[2]);
180 void turnR(
double v) { mTurn[1] = v; }
183 void turnU(
double v) { mTurn[0] = v; }
186 void turnF(
double v) { mTurn[2] = v; }
215 mPullBack0 = v > 0. ? v : 0.;
223 Vec3d mMove0, mMove1;
224 Vec3d mSpin0, mSpin1;
230 double mPullBack0, mPullBack1;
250 void nav(
Nav &n) { mNav = &n; }
251 Nav &nav() {
return *mNav; }
252 const Nav &nav()
const {
return *mNav; }
260 void active(
bool b) {
265 bool active() {
return mActive; }
266 void enable() { active(
true); }
267 void disable() { active(
false); }
268 void toggleActive() { active(!active()); }
270 double vscale()
const {
return mVScale; }
271 NavInputControl &vscale(
double v) {
276 double tscale()
const {
return mTScale; }
277 NavInputControl &tscale(
double v) {
282 void useMouse(
bool use) { mUseMouse = use; }
289 double mVScale, mTScale;
void updateDirectionVectors()
Update coordinate frame basis vectors based on internal quaternion.
void spinR(double v)
Set angular velocity around right vector (elevation), in radians.
Nav & halt()
Stop moving and spinning.
Pose vel() const
Get current linear and angular velocities as a Pose.
const Vec3d & ur() const
Get right unit vector.
void move(double dr, double du, double df)
Set linear velocity.
void turnF(double v)
Turn by a single increment, in radians, around the forward vector (bank)
Pose & transformed()
Get transformed pose.
void step(double dt=1)
Accumulate pose based on velocity.
void moveU(double v)
Set linear velocity long up vector.
void spinU(double v)
Set angular velocity around up vector (azimuth), in radians.
void spinF(double v)
Set angular velocity around forward vector (bank), in radians.
void spin(const Quatd &v)
Set angular velocity from a unit quaternion (versor)
void nudge(double dr, double du, double df)
Move by a single increment.
void turn(double az, double el, double ba)
Turn by a single increment for one step, in radians.
Vec3d & spin()
Set angular velocity directly.
void faceToward(const Vec3d &point, const Vec3d &up, double amt=1.)
const Vec3d & uf() const
Get forward unit vector.
Nav & home()
Go to origin, reset orientation.
Nav & pullBack(double v)
Set pull-back amount.
void nudgeToward(const Vec3d &p, double amt=1.)
Move toward a given world-coordinate point.
double smooth() const
Get smoothing amount.
void moveR(double v)
Set linear velocity along right vector.
void moveF(double v)
Set linear velocity long forward vector.
void turnU(double v)
Turn by a single increment, in radians, around the up vector (azimuth)
Nav(const Vec3d &pos=Vec3d(0), double smooth=0)
double pullBack() const
Get pull-back amount.
Nav & smooth(double v)
Set smoothing amount in [0,1)
void faceToward(const Vec3d &p, double amt=1.)
Turn to face a given world-coordinate point.
Nav & setHome()
set current nav to be home
Nav(const Nav &nav)
Copy constructor.
const Vec3d & uu() const
Get up unit vector.
void spin(double da, double de, double db)
A local coordinate frame.
Pose(const Vec3d &pos=Vec3d(0), const Quatd &ori=Quatd::identity())
Vec3d & pos()
Get "position" vector.
Quatd & quat()
Get quaternion component (represents orientation)
void directionVectors(Vec< 3, T > &ur, Vec< 3, T > &uu, Vec< 3, T > &uf) const
Get local right, up, and forward unit vectors.
void toEuler(T &az, T &el, T &ba) const
Convert to YXZ Euler angles (azimuth, elevation, bank), in radians.
Quat & normalize()
Normalize magnitude to one.
Controller for handling input and window events.
Vec< 3, double > Vec3d
double 3-vector
Quat< double > Quatd
Double-precision quaternion.