Problem Add a different kind of thrust effect

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,739
Reaction score
2,713
Points
203
Location
Dallas, TX
Ok How? So confused. I would think just to compare the location would be the easier but not sure.:facepalm:
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,739
Reaction score
2,713
Points
203
Location
Dallas, TX
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);
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,739
Reaction score
2,713
Points
203
Location
Dallas, TX
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.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
So.... what does that tell you? :cool: You need to __________ the ________ so that it is _____________________.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,739
Reaction score
2,713
Points
203
Location
Dallas, TX
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)
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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).
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,739
Reaction score
2,713
Points
203
Location
Dallas, TX
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 -
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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++.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,739
Reaction score
2,713
Points
203
Location
Dallas, TX
Thanks. I now get a - negative value when the DG is behind and a + value when in front.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,739
Reaction score
2,713
Points
203
Location
Dallas, TX
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?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,646
Reaction score
2,359
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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.
 
Top