Exemple #1
0
    private Vector2 drawOrbitRadiusHelper(Vector2 eccentricity, double globalRotationAngle, double semiMajorAxis, double trueAnomaly)
    {
        trueAnomaly = MiscHelperFuncs.convertTo360Angle(trueAnomaly);
        double radius = (semiMajorAxis * (1 - eccentricity.sqrMagnitude)) / (1 + (eccentricity.magnitude * Math.Cos(trueAnomaly)));

        return((float)radius * new Vector2((float)Math.Cos(trueAnomaly + globalRotationAngle), (float)Math.Sin(trueAnomaly + globalRotationAngle)));
    }
    void FixedUpdate()
    {
        //detect soi change
        if (currentMassiveBody.name != shipElements.massiveBody.name)
        {
            deleteNode();
        }

        //Have we arrived at a node?
        if (node != null)
        {
            //Is the ship moving clockwise?
            if (shipElements.Clockwise)
            {
                //TODO implement edge case when crossing over 0
                if (MiscHelperFuncs.convertTo360Angle(shipElements.TrueAnomaly) < MiscHelperFuncs.convertTo360Angle(node.getTrueAnomaly()) &&
                    MiscHelperFuncs.convertTo360Angle(lastTrueAnomaly) > MiscHelperFuncs.convertTo360Angle(node.getTrueAnomaly()))
                {
                    executeManeuver();
                }
            }
            else
            {
                if (MiscHelperFuncs.convertTo360Angle(shipElements.TrueAnomaly) > MiscHelperFuncs.convertTo360Angle(node.getTrueAnomaly()) &&
                    MiscHelperFuncs.convertTo360Angle(lastTrueAnomaly) < MiscHelperFuncs.convertTo360Angle(node.getTrueAnomaly()))
                {
                    executeManeuver();
                }
            }
        }


        //position maneuver node
        if (node != null)
        {
            positionNode();
        }
        else
        {
            nodeButton.transform.localScale         = new Vector3(0, 0, 0);
            nodePlacard.transform.localScale        = new Vector3(0, 0, 0);
            thrustVectorHandle.transform.localScale = new Vector3(0, 0, 0);
        }

        //Determine thrust vector
        if (dragging)
        {
            thrustVector = MiscHelperFuncs.convertToVec2(Camera.main.ScreenToWorldPoint(Input.mousePosition)) - (node.getNodePosition() + shipElements.GlobalTransformationVector);
        }

        //do something
        lastTrueAnomaly = shipElements.TrueAnomaly;
    }