kRPC: Control the game using C#, C++, Java, Lua, Python...

kRPC: Control the game using C#, C++, Java, Lua, Python...

7.8k Downloads

[0.4.6] Drawing.AddDirection() behavior doesn't match documentation

panourgue opened this issue ยท 1 comments

commented

Quote from documentation:

Draw a direction vector in the scene, from the center of mass of the active vessel.

Let's try:

var conn = new Connection ("Drawing");
var spaceCenter = conn.SpaceCenter ();

var targetRF = spaceCenter.TargetVessel.ReferenceFrame;

conn.Drawing ().AddDirection (
  Tuple.Create (0d, 1d, 0d),      // Up direction
  targetRF,
  2);
);

I would expect line from the CoM of the active vessel:

krpc adddirection_expected_s

But AddDirection() simply draws a vector (argument 1) in the supplied ReferenceFrame (argument 2):

krpc adddirection_observed_s

To actually get what we want, we have to:

var activeRF = spaceCenter.ActiveVessel.ReferenceFrame;

conn.Drawing ().AddDirection (
  spaceCenter.TransformDirection (Tuple.Create (0d, 1d, 0d), targetRF, activeRF),
  activeRF,
  2
);

Or, even better:

var activeRF = spaceCenter.ActiveVessel.ReferenceFrame;

conn.Drawing ().AddDirection (
  Tuple.Create (0d, 1d, 0d),
  ReferenceFrame.CreateHybrid (conn, activeRF, targetRF),
  2
);

P.S. Or am I misunderstanding something?

commented

This is indeed a bug - thanks for the detailed report! (and sorry for the delay...) Should be an easy fix.