Jump to content

kOS: How to read x,y and z from direction or vector.


inoculator

Recommended Posts

Hi guys.

I got stuck with kOS.

I try to read the absolute x,y,z values of ship:facing -just for example.

I thought of something like this:

set my_x to ship:facing:x

resulting in my_x = "210" if ship:facing would be R(10,210,45) o.s.

I cannot find any related docs on this.

any suggestion?

br

Carsten

Link to comment
Share on other sites

Hi guys.

I got stuck with kOS.

I try to read the absolute x,y,z values of ship:facing -just for example.

I thought of something like this:

set my_x to ship:facing:x

resulting in my_x = "210" if ship:facing would be R(10,210,45) o.s.

I cannot find any related docs on this.

any suggestion?

br

Carsten

The numbers in R(10,210,45) are not vector component lengths. They're degree angles of rotation *around* the main axes.

To get vector lengths, convert the Direction SHIP:FACING into a vector, by appending a :VECTOR suffix, like so: ship:facing:vector:x.

If you leave it as a direction, you get 3 rotation angles. If you turn it into a vector, what it does is rotate a starting XYZ grid by the rotation R(aaa,bbb,ccc), find out what that did to the Z axis, and take that resulting new Z axis and give you that expressed in the original raw axes, as a unit vector.

When locking steering to a Direction, you are not only telling it how to point the nose, but also how to roll the ship. It points the nose along the newly rotated Z axis, the roof along the new Y axis, and the starboard side along the new X axis. The vector version just looks at the z axis because that's the "nose-ward" one.

When locking steering to a Vector, you only are telling it the nose pointing, and it's picking something arbitrary for the other two.

As for not finding documentation: it's here: http://ksp-kos.github.io/KOS_DOC/math/direction.html

Be aware that the words "pitch", "yaw", and "roll" are words I hate, that are inherited from the original author, and changing them now would break backward compatibility too much which is the only reason they're still being used. They have NOTHING at all to do with the actual meaning of pitch, yaw, and roll, because the axes they are rotating around are the universe's axes, not the ship's axes.

Link to comment
Share on other sites

Hi Steven,

thanks for Your explanations.

I am aware of the difference between vetors and directions.

My question was, how to extract the directions from a given value.

I can extract vectors like "(kerbin:position-mun:position):x" which gives me the length on the x axis from kerbin coordinate system to the mun for example.

But how do I get the directions from "ship:facing" which gives me degrees, not vectors?

br

Carsten

Link to comment
Share on other sites

But how do I get the directions from "ship:facing" which gives me degrees, not vectors?

It was on the page I linked to. That's what I was talking about when I said I don't like the names "pitch", "yaw", and "roll". Those *are* the suffix names that give you those degree angles, but they're a misnowmer - they're not really pitch, yaw, and roll as pilots understand the terms and should have never been named that. But it's what they're called and we're stuck with it.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...