Open Arrowstar opened 3 years ago
kOS has vector and direction operations native because they are native to KSP/unity and thus very easy to implement.
Something like this is better done as an addon to kOS or a kerboscript library not as a feature set of the main language.
The other issue with implementing such a feature is quantifying the "cost" of an operation. As with out a balanced instruction cost and the ability to suspend in the middle of operations which only really comes with being written in kerboscript could easily lead to massive lag which is something we try to avoid including in the mod.
Got it, thanks! And thanks for linking to the library, I did not know it existed. I think you can close this.
I only work on the KSlib subsection of kOS not the main mod so while I am a member I have no control over issues on the main repo and thus can't close issues.
It's not a bad idea at all. It's just that I'm the mod maintainer and my math experience only barely touched on matrix algebra. I had a course on it eons ago and haven't used it since, so I'm very rusty. I wouldn't be a good expert on how best to implement it.
No worries! You might take a look at Math.NET. It has a linear algebra package built for C#. I have no idea what it would take to implement in kOS, but it's an idea anyways.
It would be great to see linear algebra operations officially supported in kOS to handle complex vextor and matrix math operations. While someone could certainly write a linear algebra library for kOS, what would be really nice to see is OpenBLAS (or similar) integration into kOS. I think there is some of this functionality built in under the hood for the Vector and Direction classes, but it would be great for it to be more generalized to Lists, 2D Lists, etc.
For example, it would be nice to be able to do:
Set a to List(0, 1, 2) - 2.
And have "a" return a list in which each element is less by two. Consider similar for general vector and matrix multiplication, and so forth.