Open weissel opened 10 years ago
From memory you need to use R(p,r,y) * up (or it may be up * R(p,y,r)
(fixed formatting)
yes, it stole my *
firstly... you're moving, so use LOCK dir TO .... so that you get the current value of UP whenever you evaluate it.
you want to use
LOCK dir TO UP * R(-70,0,180).
WAIT UNTIL ABS(dir:PITCH - FACING:PITCH) < 0.5
AND ABS(dir:YAW- FACING:YAW) < 0.5.
beware of gimble lock - don't know it it's a problem (will only be an issue when pitch nearly straight up or down).
Gimble lock is an issue R(90,90,0) is the same as R(90,0,-90), but doesn't cause a problem as it is normalised out as long as you compare up*dir against facing.
and as a final note @weissel theres the edge case where you're heading due south, so you need to check for yaw > 359.5.
I hope it normalises, otherwise it starts to get messy....
I actually use
wait until abs(sin(fset:pitch) - sin(facing:pitch)) < tolerance and abs(sin(fset:yaw) - sin(facing:yaw)) < tolerance.
to solve issues when yaw or pitch > 360 which I have observed. Normalisation does not work in some cases. Also if fset:pitch is set to 0 and facing:pitch is 359.5 then sin will get you around it nicely.
I had a hunt around and couldn't find anywhere where the normalisation didn't work - could you give an example so I can test my routines @baloan ?
@JoCRaM Yep, multiplication works. Unfortunately, everyone and their dog (official documentation and KOS Wiki, for example) seems to use/advocate up + R(...)
, not up * R(...)
or similar.
Yes, using Eulers, as long as UP is close to R(0,Y,R) adding the angles is pretty much the same as doing it properly - and most stuff people do is either near KSC, or an equatroial orbit, so the little bit of error that creeps in gets cancelled by fudges and control loops.
Near KSC:
Now go to 45-50° north.
(Yeah, I used some unlimited fuel and hack gravity, as I landed dry.)
It DOES work at near vertical, though, it only fails when having a rather shallow angle.
This is causing me grief when trying to find out if my craft (jet engine with tanks --- no proper wings yet, so flying at 20-30° pitch up) is pitched like it should be pitched by comparing
facing:pitch
withdir:pitch
.