General Question What is "VECTOR3 rofs" ?

johnnymanly

Donator
Donator
Joined
Mar 17, 2008
Messages
179
Reaction score
116
Points
43
Location
Southwest Pennsylginia
Website
sites.google.com
I wrote this some time ago following a tutorial
C++:
VESSELSTATUS vs;
    char name[256];
    VECTOR3 sofs = _V(-0.46, 0, 11.25);
    VECTOR3 sdir = _V(-1, 0, 0);
    double svel = 4.0;

    // Get vessel status structure
    VECTOR3 rofs;
    GetStatus (vs);
    Local2Rel (sofs, vs.rpos);
    GlobalRot (sdir, rofs);
    vs.rvel += rofs*svel;
    vs.vrot.y = 0.4;

    // Create fairing as separate vessel
    strcpy (name, GetName());
    strcat (name, "-Fairing1");
    oapiCreateVessel (name, "OmegaFairing1", vs);
But I never figured out what "VECTOR3 rofs " was.
the tutorial called it a "place holder".
What is it?
 
It's just a temporary variable used to store the result of GlobalRot.
if sdir is the separation direction in the vessel frame, rofs is the rotated direction in global frame (and proxy planet frame too I guess?).

vs.vel += rofs * svel; then just adds the separation velocity in the proxy planet frame to the velocity of the current vessel.
Would have been better to call it rdir maybe
 
I'm coming to grips with it but I'm not a very experienced coder.
I'm converting that code to Lua and in order for me to get it working I had to give the variable "rofs" a value.
Code:
local vs = vi:get_rawstatus(1)
  local t = vs:get()
  local sdir = {x=-1,y=0,z=0}
  local svel = 4.0
  local rofs = {x=-1,y=0,z=0}
  vi:globalrot(sdir, rofs)
  t.rvel.x = t.rvel.x + rofs.x * svel
  t.rpos = vi:local2rel({x=-0.46,y=0,z=11.25})
  t.vrot = {x=0,y=0.5,z=0}
  vs:set(t)
  oapi.create_vessel("OmegaFairing1", "OmegaFairing1", vs)
this works as advertised but I'm not sure it's correct.
 
Back
Top