General Question Plane changes give me a bad attitude

Mipada

New member
Joined
Feb 22, 2015
Messages
22
Reaction score
0
Points
1
In the Orbiter.pdf (v. 2016) on page 62 there is that lovely diagram showing the attitude of the ship at prograde, retrograde, orbit normal and orbit anti-normal. It seems that rolling from one to the other would be more fuel efficient if the ship rolled only on one axis.(*) The roll code probably uses SLERP (sorry, I haven’t looked at any Orbiter code). It seems like a simple modification would make it roll only on one axis (if it were already in a prograde, retrograde, normal or anti-normal attitude). If nobody is sitting on the code at the moment, I can come up with something but, I have not yet set up the SDK. **

For example:
* Hum... when the Enterprise enters orbit, it has the port side of the ship towards the planet. If it needed to make a plane change, it could roll only on it’s X axis to go to a normal/anti-normal attitude; keeping port side towards the planet still (for a counter clockwise orbit). If you had the belly of the DG-4/5 pointed at the planet, it would be a roll on the Y axis. (Y is up in Orbiter, isn’t it?)

Which leads to: Can a setting be added to choose between port side, starboard side, belly side or top side (oh, or front or back) to face the orbiting body or the galactic plane? Then the roll code could check it and set the final orientation of the roll according to the users preference and, if already orientated, roll only on the axis that points to the orbiting body. (Ok, I’m only a little obsessive compulsive but, this would make me feel better. LOL)

** You’ll have to pardon my level of explanation. Experience tells me that, when I ask a question, I assume a lot, leave out a lot, leaving a lot unclear. I don’t want to talk down to anyone but, if I miss a detail, someone will ask about it.
(If you agree, please like this question. LOL)
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
No, what you say makes perfect sense, and it shouldn't be too hard to implement. If you don't want to go right into the SDK, you could try to test your algorithm with a quick Lua script first.

Although you might also want to have a look at the available addons. Attitude MFD comes to mind. Maybe this already does what you want.
 

vedika31

New member
Joined
Feb 20, 2019
Messages
1
Reaction score
0
Points
0
Website
crbtech.in
It will be great if you could tell us how to test algorithm with a quick Lua Script first.
 

Sbb1413

Well-known member
Joined
Aug 14, 2018
Messages
948
Reaction score
373
Points
78
Location
India
Preferred Pronouns
he/his/him
Just a greeting

Another Indian in this backyard!? Namaste!
 

Mipada

New member
Joined
Feb 22, 2015
Messages
22
Reaction score
0
Points
1
I did it

Better Update of Rotational Properties (BURP) tries to fix the rolling. It subtracts the prograde rotation from the current rotation, finds the shortest path (rather than just using whatever the difference is even if it takes the long way around), finds the longest of the x, y, z angles, and then uses the inverse of the time (1 – t) to calculate which axis to rotate and how much change to make. Note: it only does the heavy calculations on the first pass through and saves the results for later iterations.

I have not located Orbiter on Github or Subversion. Is it out there?
Does anyone have a library that can give the prograde, retrograde, etc. orientations for the current orbit? All I can find is orbital velocity but, it doesn’t tell which direction it faces.
I’m no mathematician. Can anyone add the spherical part with sin and cos?
Also, can anyone explain how normalizing works in a quaternion, since the w component should be between 0 and 1 but, when you normalize it, it gets normalized with the other components. Or, are the other components clobbered and get clipped to 0 and 1 instead of going from –PI to PI.

See code below.
On Github is the full Quaternion file. It is borrowed from JMonkeyEngine - with disclaimer attached!
You can play with it or use my test app, BURPTest on github.
https://github.com/Mipada/BURPTest
If anyone is good at math and can add the sin and cos to make it SLERPish, that would be appreciated.
I'll look into Lua.

```
Code:
    //Basic Update of Rotation Properties
    //still need to convert to slerp (with sin/cos)
    float PI2f = (float)Math.PI * 2f;
    float PIf = (float)Math.PI;
    Quaternion diff = null;
    Vector4f r = new Vector4f();
    float max = 0.0f;
    public Quaternion burp(Quaternion q0, Quaternion q1, float t){
        return burp(q0, q1, t, false);
    }
    
    public Quaternion burp(Quaternion q0, Quaternion q1, float t, boolean initialize){
        boolean debug = true;
        //q0.normalizeLocal();//q0 = q0.normalize()
        //q1.normalizeLocal();//q1 = q1.normalize()
        
        if (q0.x == q1.x && q0.y == q1.y && q0.z == q1.z && q0.w == q1.w) {
            if (debug) System.out.println("BRUP.Ship.update() q0 = q1");
            this.set(q1);
            return this;
        }

        //set diff, max
        if (initialize){
            if (debug) System.out.println("BRUP.Ship.update() initializing");
            if (debug) System.out.println("q0=" + q0);
            if (debug) System.out.println("q1=" + q1);
            //not the result but the value of diff
            if (diff == null) diff = new Quaternion();
            diff = q1.subtract(q0);
            if (diff.x > PIf){
                diff.x = diff.x - PI2f;
            }
            else if (diff.x < -PIf){
                diff.x = diff.x - PI2f;
            }

            if (diff.y > PIf){
                diff.y = diff.y - PI2f;
            }
            else if (diff.y < -PIf){
                diff.y = diff.y - PI2f;
            }

            if (diff.z > PIf){
                diff.z = diff.z - PI2f;
            }
            else if (diff.z < -PIf){
                diff.z = diff.z - PI2f;
            }

            if (diff.w > PIf){
                diff.w = diff.w - PI2f;
            }
            else if (diff.w < -PIf){
                diff.w = diff.w - PI2f;
            }
            if (debug) System.out.println("diff=" + diff);
            //find max
            max = 0.0f;
            if (debug) System.out.println("abs of x=" + Math.abs(diff.getX()) + ", max=" + max);
            max = Math.abs(diff.x);
            if (debug) System.out.println("set max to x's max (" + max + ")");

            if (debug) System.out.println("abs of y=" + Math.abs(diff.getY()) + ", max=" + max);
            if (Math.abs(diff.y) > max){
                max = Math.abs(diff.y);
                if (debug) System.out.println("set max to y's max (" + max + ")");
            }

            if (debug) System.out.println("abs of z=" + Math.abs(diff.getZ()) + ", max=" + max);
            if (Math.abs(diff.z) > max){
                max = Math.abs(diff.z);
                if (debug) System.out.println("set max to z's max (" + max + ")");
            }

            //if (debug) System.out.println("abs of w=" + Math.abs(diff.getW()) + ", max=" + max);
            //if (Math.abs(diff.getW()) > max){
            //    max = Math.abs(diff.getW());
            //    System.out.println("set max to w's max (" + max + ")");
            //}
        }//end init
        
        r.x = q0.getX();
        r.y = q0.getY();
        r.z = q0.getZ();
        r.w = q0.getW();
        
        //BURP
        if ((float)Math.abs(diff.getX())/max > (1f - t)){//inverse of time
            if (debug) System.out.print("x, ");
            r.x = q0.getX() + t * diff.getX();
        }
        if ((float)Math.abs(diff.getY())/max > (1f - t)){
            if (debug) System.out.print("y, ");
            r.y = q0.getY() + t * diff.getY();
        }
                
        if ((float)Math.abs(diff.getZ())/max > (1f - t)){
            if (debug) System.out.print("z, ");
            r.z = q0.getZ() + t * diff.getZ();
        }
                
        //if ((float)Math.abs(diff.getW())/max > (1f - t)){
        //    System.out.print("w, ");
         //   r.w = q0.getW() + t * diff.getW();
        //}
        
        //noralize/clip
        if (r.x > PIf) r.x -= PI2f;
        else if (r.x < -PIf) r.x += PI2f;

        if (r.y > PIf) r.y -= PI2f;
        else if (r.y < -PIf) r.y += PI2f;

        if (r.z > PIf) r.z -= PI2f;
        else if (r.z < -PIf) r.z += PI2f;

        //if (r.w > PIf) r.w -= PI2f;
        //else if (r.w < -PIf) r.w += PI2f;
        
        //set
        set(r.x, r.y, r.z, r.w);
        return this;
    }
[\code]
```
 
Top