Project Energia 5V Heavy Launch Vehicle

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
So is there any kind of solution to this ? I'm completely confused... I mean its math, there's a solution or there's no solution...

z alone won't work at all, because its the "prograde" component of my vector. It would turn the engine gimbal into some kind of magic throttle.

Its rather serious stuff, I mean theres no point making cool addons with tons of features if we can't even calculate good vectors.
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Well, if you plan to rotate everything around the Z axis (in the XY plane), the z component of a vector is unchanged.

The trick is remembering that sin²x + cos²x = 1 (Pythagoras)

What you need, is just a transformation matrix (at least on the paper, but having it defined as constant and using matrix multiplication is more reliable) with the rotation axis around Z and an angle a.

something like:


(Sorry, O-F has a bug rendering tables it seems)


Multiplying this with a vector (x, y, z) would mean as result: _V(x * cos(a) - y*sin(a), x * sin(a) + y * cos(a), z)
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse

That one is even better :

 
Last edited:

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
The second one applies very well to spaceflight... Now I get why mission controllers seem very worried about "being close of gimbal lock" on the Apollo 13 tapes... It would mean the whole inertial system sort of collapses...
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
The second one applies very well to spaceflight... Now I get why mission controllers seem very worried about "being close of gimbal lock" on the Apollo 13 tapes... It would mean the whole inertial system sort of collapses...

Yes, it would become impossible to tell in around which reference coordinate axis an rotation really takes place, from measuring the rotation of the body, since two gimbals are parallel. For avoiding this Gemini and the Space Shuttle had a fourth gimbal, that prevented this situation - should one gimbal ever come to close to another, the fourth would rotate them apart.
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
So, it took me some time to grasp that matrix concept, which again is a new thing to me. So, as far as I can tell :

The matrix below is what I need to do :

RotationMatrix.png

I know the axis u, its the one I use for my engine gimbal animation. That vector is the direction in which the thrust vector will be "deflected". I want a x,y 45° direction so it will be u = _V(cos(45), cos(45), 0) which is roughly equal to _V(0.707, 0.707, 0). That vector is a unit vector (a normalized vector of magnitude = 1) because sqrt(cos(45))+sqrt(cos(45))+sqrt(0) = 0.5+0.5+0 = 1.

I also know the angle "Theta" (the greek letter above), which is how much I want to rotate my thrust vector. That angle is defined by my engine gimbal range. RD171 nozzles are tightly packed so I know from my animations that +-2DEG is the value I want (more and the nozzles collide each other). Its not much but given I have 20 nozzles, it will be enough (even if I don't use them all). So Theta = 2DEG or Theta = 2xPI/180 (in RADs)

Now I should have everything I need to "solve" the matrix above. What still confuses me is that I will end with 9 values, and I'm not sure about which ones I should keep (I need 1 of each column or row, because I need x, y, z components to compute my thrust vector. Maybe the "diagonal" set of values ? :unsure:

Thanks for input, I'd like to know if I'm on the right track... :coffee:
 
Last edited:

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,696
Reaction score
1,355
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
With rotational matrices you multiply the matrix by your origional vector. The result will be a new vector with 3 values, not 9. This new vector will be the origional vector rotated by however much the rotational matrix specifies. General the rotational matrix is specified in terms of Eüler angles.
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
The result will be a new vector with 3 values, not 9

Yes, but how do I know which 3 values I should keep ?
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
I don't get it. In the image you linked there are 3 "xyz" on the right :

a.x, b.y, c.z
d.x, e.y, f.z
g.x, h.y, i.z

How do I know which triplet is the good ?
 

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,696
Reaction score
1,355
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
Its ax + by + cz etc

Each row in that vector is a single value.
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
So the result is like _V(ax+by+cz, d.x+e.y+f.z, g.x+h.y+i.z) ?

Its ax + by + cz etc

Can you elaborate a bit ? Many thanks, I feel I'm getting close.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
So the result is like _V(ax+by+cz, d.x+e.y+f.z, g.x+h.y+i.z) ?



Can you elaborate a bit ? Many thanks, I feel I'm getting close.

Do you know how to do a matrix multiplication on a sheet of paper? Lets start like that:

683px-Matrix_multiplication_diagram_2.svg.png


As you can see, the row of the first factor in the multiplication gets multiplied by a column of the second factor, all that happens there now is a simple dot product of the two similar sized vectors represented by row and column.

Like c_1,2 = a_1,1 * b_1,2 + a_1,2 * b_2,2
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
Do you know how to do a matrix multiplication on a sheet of paper? Lets start like that:

No I don't, the most advanced math stuff I studied at school was 2D trigonometrics. I wasn't good at math at all so I didn't specialize in that way but I sort of regret it and am willing to learn. I want to know how it works so that I can apply it to other cases (all kinds of animations, multiple engines that gimbal on two axis, etc..)
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
No I don't, the most advanced math stuff I studied at school was 2D trigonometrics. I wasn't good at math at all so I didn't specialize in that way but I sort of regret it and am willing to learn. I want to know how it works so that I can apply it to other cases (all kinds of animations, multiple engines that gimbal on two axis, etc..)

Its not like many people need that kind of math in their life. Except you get into making Orbiter add-ons, of course.
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
So I have to multiply my thrust vector by the rotation matrix formula I posted above. My thrust vector "v" will be like _V(0,0,1), because it is a "standard" Orbiter prograde thruster. So I make the multiplication (v*rotation matrix) and then I sum each "line" : a+b+c will give the x component, d+e+f the y, g+h+i the z.

One last question : where should I put the "variable input" ? By "variable input" I mean a value between -1 and 1 * the engine max gimbal range that describes the current position of the nozzle. Directly into my thrust vector "v" ? I'm not sure of that at all. :unsure:

Well the input should probably be proportional with the rotation angle "Theta" defined in the matrix, so I'll try that.
 
Last edited:

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
I get zeroes all the way because in my vector v = _V(0,0,1) the two first components are equal to 0. It won't work that way.

So the first two components should be relative to the input. They are equal to 0 when there is 0 input. But should they be equal to 1 or -1 when there is full input ? No, it doesn't make sense. If I go any further, I'm trying to get my result thrust vector. But my input vector is not my thrust vector. I'm lost. :unsure::unsure::unsure:?
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
@N_Molson
Maybe you can grasp it better by debugging?
The OrbiterAPI.h includes many of the types and operations you'll need (I've cut out only the relevant parts):
C++:
// ===========================================================================
/**
* \defgroup vec Vectors and matrices
* Vectors and matrices are used to represent positions, velocities, translations,
*   rotations, etc. in the 3-dimensional object space. Orbiter provides the
*   %VECTOR3 and %MATRIX3 structures for 3-D vectors and matrices. A number
*   of utility functions allow common operations such as matrix-vector
*   products, dot and vector products, etc.
*/
// ===========================================================================
//@{
/**
* \brief 3-element vector
*/
typedef union {
    double data[3];               ///< array data interface
    struct { double x, y, z; };   ///< named data interface
} VECTOR3;


/**
* \brief 3x3-element matrix
*/
typedef union {
    double data[9];               ///< array data interface (row-sorted)
    struct { double m11, m12, m13, m21, m22, m23, m31, m32, m33; }; ///< named data interface
} MATRIX3;

//@}


// ======================================================================
// Some helper functions
// ======================================================================

/**
* \ingroup vec
* \brief Vector composition
*
* Returns a vector composed of the three provided arguments
* \param x x-component
* \param y y-component
* \param z z-component
* \return vector defined as (x,y,z)
*/
inline VECTOR3 _V(double x, double y, double z)
{
    VECTOR3 vec = {x,y,z}; return vec;
}


/**
* \ingroup vec
* \brief Matrix composition
*
* Returns a matrix composed of the provided elements.
* \return
* \f$
*  \left(\begin{array}{ccc}
*  m_{11} & m_{12} & m_{13} \\
*  m_{21} & m_{22} & m_{23} \\
*  m_{31} & m_{32} & m_{33}
*  \end{array}\right)
* \f$
*/
inline MATRIX3 _M(double m11, double m12, double m13,
                  double m21, double m22, double m23,
                  double m31, double m32, double m33)
{
    MATRIX3 mat = {m11,m12,m13,  m21,m22,m23,  m31,m32,m33}; return mat;
}


/**
* \ingroup vec
* \brief Matrix-vector multiplication
* \param[in] A matrix operand
* \param[in] b vector operand
* \return Result of <b>Ab</b>
*/
inline VECTOR3 mul (const MATRIX3 &A, const VECTOR3 &b)
{
    return _V (
        A.m11*b.x + A.m12*b.y + A.m13*b.z,
        A.m21*b.x + A.m22*b.y + A.m23*b.z,
        A.m31*b.x + A.m32*b.y + A.m33*b.z);
}

With this you could try something like this...

C++:
auto v = _V(1,2,3); // [v]ector (a.k.a. 1x3 matrix)
auto m = _M(11,12,13, 21,22,23, 31,32,33); // [m]atrix (3x3)

auto r = mul(m,v); // [r]esult

auto a = r.x; // should be a double
auto b = r.y; //   "    "  "   "
auto c = r.z; //   "    "  "   "
... and step into (F11) the code, so you can see exactly what is multiplied with what.

Maybe this helps
 
Top