When taking the cross product of the East and North unit vectors the result is a vector pointing down, but I believe it should point up.

To check this, I logged the difference between

(Position + cross(East, North)*100) to lat/long/agl

and

(Position) to lat/long/agl

which resulted in (0, 0, -100). Can someone explain this please?

Tags
Vizzy

5 Comments

  • Log in to leave a comment
  • Profile image

    @sflanker thanks for investigating and thanks @AndrewGarrison for answering.

    4.6 years ago
  • Profile image
    Mod sflanker

    @AndrewGarrison well that explains it then. Thanks.

    4.7 years ago
  • Profile image

    @sflanker We're using Unity's cross product function and Unity uses the left-hand rule.

    +1 4.7 years ago
  • Profile image
    Mod sflanker

    @AndrewGarrison can you help me out? The only way I can make the vector math work is if the Position vectors are actually reversed (vectors from the craft toward the center of the planet instead of the other way around). For example North ⨯ norm(position) should be equal to East should it not? But in reality it is -1 * East. I'm using version 0.9.300.5 FWIW. It is entirely possible that I'm doing something stupid, in which case I apologize for bothering you (checks to see if he's been using the correct hand when applying the right hand rule).

    4.7 years ago
  • Profile image
    Mod sflanker

    TLDR:

    instead of using the cross product of the North and East vectors, just normalize your position vector, that will always point "up" with respect to the planet.


    It looks like you have an understanding of PCI coordinates so I won't belabor that. Instead I'll walk through the steps you're taking here one by one.


    First, the East Vector returned by the Nav [East] craft information expression, will be a unit vector oscillating from (1, 0, 0) to (0, 0, 1) to (-1, 0, 0) to (0, 0, -1) as the planet rotates, or as you move around the planet heading east.

    Next we have the North Vector from Nav [North]. At the equator this vector is very simple: (0, 1, 0) as you move away from the equator it gets more complicated because it will remain tangential to the surface of the planet, so lets just stick with the scenario where we are at the equator (which is where the Launch Pad is and that is where I presume your craft is).


    Next you're taking the cross product of these two vectors, which you clearly are aware returns a vector perpendicular to both the input vectors. However, there are two such vectors, one pointing up relative to the plane represented by the input vectors, and one pointing down. Which one you get will depend on the order you put the vectors in. According to the right and rule (with your pointer finger in the direction of the first vector, palm facing the direction of the second vector, your thumb should point in the direction of the cross product), it seems to me that your expectation should be correct. So now I'm going to look at the actual math.

    [a] cross [b] = vec [aʸ * bᶻ - aᶻ * bʸ], [aᶻ * bˣ - aˣ * bᶻ], [aˣ * bʸ - aʸ * bˣ]

    Give this arbitrary East vector I get when I launch: (0.115, 0, -0.993), if I calculate the cross product with North (0, 1, 0) after simplification thanks the the zeros: (vec [0 - aᶻ], [0], [aˣ]), I get (0.993, 0, 0.115). If I graph these three vectors using https://academo.org/demos/3d-vector-plotter/ they do indeed match the right hand rule, however when I compare this vector to my normalized position vector it is opposite: `(-0.993, 0, -0.155). So I am quite confused by this.

    For the moment one quick fix is to reverse the order of North and East in the cross product expression. Another quick fix is instead of using the cross product of the North and East vectors, just normalize your position vector, that will always point up with respect to the planet. I'm still doing a little more investigation to figure out why this is happening, I'll let you know if I figure it out.

    +2 4.7 years ago

1 Upvote

Log in in to upvote this post.