Problem Add a different kind of thrust effect

Ok back to being lost. In the image the DG is in front of the vessel. costgt is .42 and COSCONE is .525. So costgt is less than COSCONE.


Because REFVEC and tgt are in different coordinate systems. You need to project REFVEC into global coordinates (GlobalRot) first, before using it that way.
 
Ok How? So confused. I would think just to compare the location would be the easier but not sure.:facepalm:
 
Ok How? So confused. I would think just to compare the location would be the easier but not sure.:facepalm:

Code:
VECTOR3 refvec = GlobalRot(REFVEC);

#ilovelinearalgebra #transformation #mathiscool
 
Thanks. I get this error:
.\NEB.CPP(946) : error C2660: 'VESSEL::GlobalRot' : function does not take 1 arguments
Code:
for ( unsigned int i = 0; i<cnt; i++)
{hv = oapiGetVesselByIndex (i); 
//if (hV == GetHandle()) continue;
if (hme == hv) continue;
oapiGetGlobalPos (hv, &tpos);
d=dist (gpos,tpos);
oapiGetRelativePos(hme, hv, &tgt);
CONE_ANGLE=45;
const double COSCONE = cos(CONE_ANGLE);
    VECTOR3 refvec = GlobalRot(REFVEC);

  REFVEC=_V(0,0,1);

 sprintf(oapiDebugString(),"costgt%2f COSCONE%2f ",costgt,COSCONE);
 
 costgt = dotp(tgt, REFVEC)/ length(tgt);
 
Thanks. I get this error:
.\NEB.CPP(946) : error C2660: 'VESSEL::GlobalRot' : function does not take 1 arguments

Then I did simply not remember the function signature correctly. Contrary to you, I don't have the API Reference close, I have to work off the top of my head.
 
Ok Thanks. Here you go:

8.51.3.255 void VESSEL::GlobalRot (const VECTOR3 & rloc, VECTOR3 & rglob) const
Performs a rotation of a direction from the local vessel frame to the global frame.
Parameters:
rloc point in local vessel coordinates
! rglob rotated point
Note:
This function is equivalent to multiplying rloc with the rotation matrix returned by GetRotationMatrix.
Should be used to transform directions. To transform points, use Local2Global, which additionally
adds the vessel’s global position to the rotated point.
 
So.... what does that tell you? :cool: You need to __________ the ________ so that it is _____________________.
 
Mybe I need another vector for REFVECG (global).

Ah well... I better bail out of here, because this is no longer about support for the suggestion that I posted.
 
Maybe it the no caffeine for me today. But the first vector REFVEC is local, right? And I need another REFVECG.

As I see it "Performs a rotation of a direction from the local vessel frame to the global frame."

So doesn't it Take REFVEC(local) and convert to REFVECG(global)
 
Maybe it the no caffeine for me today. But the first vector REFVEC is local, right? And I need another REFVECG.

As I see it "Performs a rotation of a direction from the local vessel frame to the global frame."

So doesn't it Take REFVEC(local) and convert to REFVECG(global)

Exactly that. And you can do that by that function or by taking the rotation matrix once and using it for multiple projections at once (since it is much faster that way).
 
Ok I have this as the code:
Code:
DWORD cnt= oapiGetVesselCount();  {
OBJHANDLE hme = GetHandle(),hv; 
VECTOR3 gpos,tpos,WHERETARGET,REFVEC,REFVECG,tgt,refvec;
GetGlobalPos (gpos);
double d,CONE_ANGLE;

for ( unsigned int i = 0; i<cnt; i++)
{hv = oapiGetVesselByIndex (i); 
//if (hV == GetHandle()) continue;
if (hme == hv) continue;
oapiGetGlobalPos (hv, &tpos);
d=dist (gpos,tpos);
oapiGetRelativePos(hme, hv, &tgt);
CONE_ANGLE=45;
const double COSCONE = cos(CONE_ANGLE);
    GlobalRot(REFVEC,REFVECG);

  REFVEC=_V(0,0,1);

 sprintf(oapiDebugString(),"costgt%2f COSCONE%2f ",costgt,COSCONE);
 
 costgt = dotp(tgt, REFVECG)/ length(tgt);

When I run it I get a value that change with direction. So I apply forward speed the costgt goes from - to + and retro changes = to -
 
Ok I have this as the code:
When I run it I get a value that change with direction. So I apply forward speed the costgt goes from - to + and retro changes = to -

Hardly a surprise since you calculate costgt AFTER you printed it to the debug string. Inversion of causality is not allowed in C++.
 
Thanks. I now get a - negative value when the DG is behind and a + value when in front.
 
Thanks. I now get a - negative value when the DG is behind and a + value when in front.

That should be expected. The scalar product is -1 if you have two opposing vectors of length 1 (or better: where the product of the two lengths is 1). If one vector is perpendicular to the other, the scalar product is 0.
 
Thanks. So now i just check if + value on (0,0,1) vessel in front - value on 0,0,1 vessel behind. Do the same for (1,0,0) and (0,1,0), right?
 
Thanks. So now i just check if + value on (0,0,1) vessel in front - value on 0,0,1 vessel behind. Do the same for (1,0,0) and (0,1,0), right?

Yes, if you need to.
 
Back
Top