Skip to content

Please add a ship API that returns the relative offset of the center-of-mass from some useful fixed reference point. #20

@onehittoaster

Description

@onehittoaster

I have a need in CC to determine where (x,y,z offset from any corner) where the center of mass ("COM") is. I propose something like ship.getCenterOfMassOffset() that would return a {x,y,z} vector (table of 3 floating-point numbers) that gives the COM offset relative to the CC computer executing that API.

Example: Consider a ship that is 31 x 12 x 31 blocks. ship.getSize() returns {31, 12, 31}. If the COM is perfectly centered, and the CC computer were in the very center, then ship.getCenterOfMassOffset() would return {0,0,0}. If there was a large weight in the +Z side of the ship, shifting the COM to the +Z axis, and the CC computer were on the top center, then ship.getCenterOfMassOffset() might return something like {0, -8, 4}.

I had originally thought that the COM offset should be relative to the minimal {x,y,z} coords in the shipyard, but that would not be as useful as knowing it relative to a CC computer (which is not likely to get moved around the ship).

Rationale: I expect the COM to change during combat (armor gets blown off, attacker lands and attached gold blocks to one side of the ship, etc...). My flight control software already knows the relative position of each propeller bearing (relative to the perfect physical center of the ship), and it can theoretically compensate with unbalanced thrust if the ship's geometry changes, but I have no easy way to detect this change on the fly.

In a discord chat, "zyxkad" proposed that I cache the shipyard position of the ship before combat, and check that during combat to see if it changes. That should work, but we also agreed that having a formal API would be nicer. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions