1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-09 15:39:55 +00:00

twist::formula_exp now returns shiftpoint

This commit is contained in:
Zeno Rogue 2024-07-15 09:03:58 +02:00
parent cdcd2aee21
commit 8823afc8d2
2 changed files with 7 additions and 5 deletions

View File

@ -155,6 +155,8 @@ struct transmatrix {
struct shiftpoint {
hyperpoint h;
ld shift;
shiftpoint() {}
shiftpoint(hyperpoint _h, ld _shift) : h(_h), shift(_shift) {}
ld& operator [] (int i) { return h[i]; }
const ld& operator [] (int i) const { return h[i]; }
inline friend shiftpoint operator + (const shiftpoint& h, const hyperpoint& h2) {
@ -1651,7 +1653,7 @@ EX hyperpoint direct_exp(hyperpoint v) {
#endif
#if MAXMDIM >= 4
if(nil) return nilv::formula_exp(v);
if(sl2 || stretch::in()) return stretch::mstretch ? nisot::numerical_exp(v) : twist::formula_exp(v);
if(sl2 || stretch::in()) return stretch::mstretch ? nisot::numerical_exp(v) : unshift(twist::formula_exp(v));
#endif
if(gproduct) return product::direct_exp(v);
ld d = hypot_d(GDIM, v);

View File

@ -2570,11 +2570,11 @@ EX namespace twist {
/** @brief exponential function for both slr and Berger sphere */
EX hyperpoint formula_exp(hyperpoint vel) {
EX shiftpoint formula_exp(hyperpoint vel) {
bool sp = sphere;
ld K = sp ? 1 : -1;
if(vel[0] == 0 && vel[1] == 0 && vel[2] == 0) return C0;
if(vel[0] == 0 && vel[1] == 0 && vel[2] == 0) return shiftpoint(C0,0);
ld len = hypot_d(3, vel);
@ -2606,7 +2606,7 @@ EX namespace twist {
ld xy = sr * sinh(k);
ld zw = cr * sinh(k);
return hyperpoint(K*xy * cos(u+beta), K*xy * sin(u+beta), zw * cos(u) - cosh(k) * sin(u), zw * sin(u) + cosh(k)*cos(u));
return shiftpoint(hyperpoint(K*xy * cos(beta), K*xy * sin(beta), zw, cosh(k)), u);
}
else {
@ -2624,7 +2624,7 @@ EX namespace twist {
ld xy = sr * sin(k);
ld zw = cr * sin(k);
return hyperpoint(K*xy * cos(u+beta), K*xy * sin(u+beta), zw * cos(u) - cos(k) * sin(u), zw * sin(u) + cos(k)*cos(u));
return shiftpoint(hyperpoint(K*xy * cos(u+beta), K*xy * sin(u+beta), zw * cos(u) - cos(k) * sin(u), zw * sin(u) + cos(k)*cos(u)), 0);
}
}