Search the Community
Showing results for tags 'quaternion'.
-
I've written a mickey-mouse prototype of what might become a true KSP extension. It automates the modification of a quicksave.sfs file to transplant a KSC aircraft on the runway or on the launchpad to the Baikerbanur cosmodrome. Everything is straightforward except for the manipulation of the VESSEL.rot quaternion that expresses the vehicle attitude (presumably in Kerbin's frame of reference). I put the same craft in both places and observed the quaternion values, K and B. Then I wrote code that, for a vessel at KSC with quaternion 'p', performed the computation q = B.(Kinv.p) The idea is to use Kinv to back out the orientation for K and then use B to orient the vehicle for the destination. I am aware that quaternion multiplication is not the same as quaternion rotation. First difficulty is that I found I had to use different numbers for the categories os SPH (horizontal) and VAB (vertical) craft and I suspect flags fall into their own category as well. I thought I had cracked the code but the last teleport attempt was of a Screechcraft Starship and it arrived at Baikerbanur in a devilish twist. All of this is (necessarily) outside of Unity for the moment, but I wondered if any sage advice might be proferred? I've had half a shot at writing a real r.q.rinv rotation but it does not look promising. Another way of looking at this would be to find a rotation that is equivalent to rotating from KSC to Baikerbanur. Both have known coordinates, e.g.: KSC: lat = -0.097168916153244286 lon = -74.557681735503166 BKB: lat = 20.652140227285638 lon = -146.42383127125942 Any thoughts about this would be appreciated.
- 4 replies
-
- 1
-
- quaternion
- rotation
-
(and 1 more)
Tagged with:
-
I'm getting a weird thing where the *compiler* claims a method exists that at *runtime* it throws an exception on and says it does not exist. It's this: System.MissingMethodException: Cannot find the requested method. at (wrapper managed-to-native) UnityEngine.QuaternionD:INTERNAL_CALL_LookRotation (Vector3d&,Vector3d&) at UnityEngine.QuaternionD.LookRotation (Vector3d forward, Vector3d upwards) [0x00000] in <filename unknown>:0 at kOS.Function.FunctionHeading.Execute (kOS.SharedObjects shared) [0x00000] in <filename unknown>:0 at kOS.Function.FunctionBase.Execute (kOS.Safe.SafeSharedObjects shared) [0x00000] in <filename unknown>:0 at kOS.Safe.Function.FunctionManager.CallFunction (System.String functionName) [0x00000] in <filename unknown>:0 at kOS.Safe.Execution.CPU.CallBuiltinFunction (System.String functionName) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.OpcodeCall.StaticExecute (ICpu cpu, Boolean direct, System.Object destination, Boolean calledFromKOSDelegateCall) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.OpcodeCall.Execute (ICpu cpu) [0x00000] in <filename unknown>:0 at kOS.Safe.Execution.CPU.ExecuteInstruction (IProgramContext context, Boolean doProfiling) [0x00000] in <filename unknown>:0 According to the compiler, UnityEngine.QuaternionD.LookRotation emphatically does exist, with those exact arguments. But at runtime it does not. I'm not sure what "INTERNAL_CALL" means, but I'm guessing it means "this isn't implemented in the normal C# way" or something like that. (i.e. maybe it's dropping down into some other language for that part, or doing something implemented in raw machine language instead of in the MSIL's opcodes?) This came about because I was trying to replace all our Quaternion usages with QuaternionD's because when working with large vectors (i.e. the distance from Kerbin to Duna, for example), the 32-bit precision of Quaternion's was beginning to multiply into rather big errors after several operations of using them to rotate those big vectors. But it looks like not everything that was implemented for Quaternion got re-implemented for QuaterionD''s. Am I going to have to resort to running my own matrix multiplications to perform rotations or is there some other solution to this?