mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-26 03:17:39 +00:00
nisot:: geodesic_step is now based on RK4 instead of midpoint
This commit is contained in:
@@ -1971,17 +1971,19 @@ EX namespace nisot {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void geodesic_step(hyperpoint& at, hyperpoint& velocity) {
|
hyperpoint get_acceleration(const hyperpoint& at, const hyperpoint& vel) {
|
||||||
auto acc = christoffel(at, velocity, velocity);
|
return christoffel(at, vel, vel);
|
||||||
|
}
|
||||||
|
|
||||||
auto at2 = at + velocity / 2;
|
EX void geodesic_step(hyperpoint& at, hyperpoint& vel) {
|
||||||
auto velocity2 = velocity + acc / 2;
|
/* RK4 method */
|
||||||
|
auto acc1 = get_acceleration(at, vel);
|
||||||
|
auto acc2 = get_acceleration(at + vel/2, vel + acc1/2);
|
||||||
|
auto acc3 = get_acceleration(at + vel/2 + acc1/4, vel + acc2/2);
|
||||||
|
auto acc4 = get_acceleration(at + vel + acc2/2, vel + acc3);
|
||||||
|
|
||||||
auto acc2 = christoffel(at2, velocity2, velocity2);
|
at += vel + (acc1+acc2+acc3)/6;
|
||||||
|
vel += (acc1+2*acc2+2*acc3+acc4)/6;
|
||||||
at = at + velocity + acc2 / 2;
|
|
||||||
|
|
||||||
velocity = velocity + acc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EX hyperpoint numerical_exp(hyperpoint v, int steps) {
|
EX hyperpoint numerical_exp(hyperpoint v, int steps) {
|
||||||
|
|||||||
Reference in New Issue
Block a user