C++ Question matrix 3 help

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
5,740
Reaction score
58
Points
123
Location
Dallas, TX
So I am trying to use this code from the shuttle on another vessel
Code:
if (SPIN1 == 1) {//spintable#1

        if ((spintable == 1) || (spintable == 3) || (spintable == 4)) {

            SPINACC = 5 * 360 / 60;

            spintable_vel = spintable_vel + SPINACC * simdt;
            spintable_phi = spintable_phi + spintable_vel * simdt;
            int multiplier = ((int)spintable_phi) / 360;

            if (spintable_vel > (50 * 360 / 60))(spintable_vel = (50 * 360 / 60));  //limit spped
            if (spintable_vel == (50 * 360 / 60)) spintable = 3;//speed achieved
            spintable_phi = spintable_phi - (double)multiplier * 360;
            MATRIX3 spintable_rotmat = rotm(_V(0, 1, 0), spintable_phi * RAD);
            SetAttachmentParams(sat_attach1, pl1_ofs, _V(spintable_rotmat.m21, spintable_rotmat.m22, spintable_rotmat.m23), _V(spintable_rotmat.m31, spintable_rotmat.m32, spintable_rotmat.m33));


            ATTACHMENTHANDLE ah = GetAttachmentHandle(false, 0);
            OBJHANDLE hChild = GetAttachmentStatus(ah);
            if (oapiIsVessel(hChild)) { // something is attached!
                VESSEL* v = oapiGetVesselInterface(hChild);
                //    sprintf(oapiDebugString(), "%s is attached",
                //    v->GetName());
            }
        }
    }
But I get this:
Severity Code Description Project Path File Line Suppression State
Error (active) E0020 identifier "rotm" is undefined VENTUREstar D:\orbiter100830\Orbitersdk\samples\VENTURESTAR D:\orbiter100830\Orbitersdk\samples\VENTURESTAR\VS.cpp 851

So what should rotm be defined as?
 

Face

Addon Developer
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,111
Reaction score
43
Points
73
Location
Vienna
It is in the stock header file OrbiterAPI.h . Perhaps you are not properly including the Orbiter libs and headers in your project.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
5,740
Reaction score
58
Points
123
Location
Dallas, TX
Thanks. do you mean in the property pages:
If I comment the MATRIX3 line then no issues, but I need those lines. If it matters it is for 2010
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
5,740
Reaction score
58
Points
123
Location
Dallas, TX
So I see what you mean in 2016 there is this:
MATRIX3 rotm (const VECTOR3 &axis, double angle) Construct a rotation matrix from an axis and an angle.
but not in 2010

So is there a way to get around it?

What it does it determine the attachment values of a spinning attachment/satellite
 

Face

Addon Developer
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,111
Reaction score
43
Points
73
Location
Vienna
Just copy it from OrbiterAPI.h into your code.
 

Face

Addon Developer
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,111
Reaction score
43
Points
73
Location
Vienna
No. Copy it from the OrbiterAPI.h file of Orbiter 2016 into your code project. It is just a helper function.
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
5,740
Reaction score
58
Points
123
Location
Dallas, TX
So this is the function:
Code:
inline MATRIX3 rotm (const VECTOR3 &axis, double angle)
{
    double c = cos(angle), s = sin(angle);
    double t = 1-c, x = axis.x, y = axis.y, z = axis.z;

    return _M(t*x*x+c, t*x*y-z*s, t*x*z+y*s,
              t*x*y+z*s, t*y*y+c, t*y*z-x*s,
              t*x*z-y*s, t*y*z+x*s, t*z*z+c);
}
so just add this into the code?
I think that works
 

Face

Addon Developer
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,111
Reaction score
43
Points
73
Location
Vienna
At the top of your code file should work, yes. If you need it in various other files as well, create your own additional header file (e.g. missingAPI.h), put it in there, then include it in all code files that use it. You can either include the Orbiter API in the header file as well (be sure to use the "#pragma once" declaration to avoid multiple declarations), or just include the additional header after the Orbiter API includes in your code file.
 
Top