Пример #1
0
        public FighterGeometry()
        {
            var nose            = new Nose(0.5f, 0.6f, 26, 0.4f);
            var cockpitFuselage = new CockpitFuselage(nose, 1.2f, 1.2f, 3f);
            var mainFuselage    = new MainFuselage(cockpitFuselage);
            var intake          = new EngineIntake(cockpitFuselage);
            var underside       = new Underside(intake);
            var canopy          = new Canopy(0.65f, 0.5f, 3f, 16);
            var wing            = new Wing(4.5f, 4.5f);
            var rear            = new Rear(mainFuselage, underside);
            var tailFin         = new TailFin();
            var stabilizer      = new Stabilizer();
            var exhaust         = new Exhaust(rear, 0.6f);
            var bottomFin       = new BottomFin();

            var path      = exhaust.FlangeEndXSection;
            var graySlide = new Vec3(1f).Interpolate(new Vec3(0f), path.Vertices.Length);

            path.Vertices.Color(graySlide);
            Paths = EnumerableExt.Enumerate(path);

            Fighter = Composite.Create(Stacking.StackBackward(cockpitFuselage.Fuselage, mainFuselage.Fuselage)
                                       .Concat(EnumerableExt.Enumerate(intake.Intake, intake.Belly, underside.Geometry, canopy.Geometry,
                                                                       wing.Geometry, wing.Geometry.ReflectX(), rear.Geometry, exhaust.Geometry,
                                                                       exhaust.StabilizerFlange, exhaust.StabilizerFlange.ReflectX(),
                                                                       tailFin.Geometry, stabilizer.Geometry, stabilizer.Geometry.ReflectX(),
                                                                       bottomFin.Geometry, bottomFin.Geometry.ReflectX())))
                      .Smoothen(0.85f)
                      .Center();
        }
Пример #2
0
        private void GetOrCreateModel()
        {
            Directory.CreateDirectory(ModelDirectory);

            // create the inputs
            Axis axis     = new Axis("inputAxis");
            var  features = Variable.InputVariable(new[] { Vocab.CharCount }, DataType.Float, "features", new List <Axis> {
                axis, Axis.DefaultBatchAxis()
            });
            var labels = Variable.InputVariable(new[] { Vocab.CharCount }, DataType.Float, "labels", new List <Axis> {
                axis, Axis.DefaultBatchAxis()
            });

            if (TryGetModel(out string filename))
            {
                // load the previous model and use it's features
                // the labels should be identical as before
                Model  = Function.Load(filename, Device);
                Inputs = new IOPair <Variable>(Model.Arguments[0], labels);
                Console.WriteLine($"Loaded {Path.GetFileName(filename)}");
            }
            else
            {
                // create a new model from the features
                Model = features;
                for (int i = 0; i < Layers; i++)
                {
                    Model = Stabilizer.Build(Model, Device);
                    Model = LSTM.Build(Model, HiddenDimensions, Device);
                }

                Model  = Dense.Build(Model, Vocab.CharCount, Device);
                Inputs = new IOPair <Variable>(features, labels);
            }
        }
Пример #3
0
 public override void ParametrizeUnityFromModel()
 {
     base.ParametrizeUnityFromModel();
     mainRotor            = _model.MainRotor;
     tailRotor            = _model.TailRotor;
     horizontalStabilizer = _model.HorizontalStabilizer;
     verticalStabilizer   = _model.VerticalStabilizer;
 }
Пример #4
0
    protected void DebugDrawStabilizer(Transform transform, Stabilizer stabilizer)
    {
        Vector3 tl = new Vector3((float)-stabilizer.span / 2, 0, (float)stabilizer.chord / 2);
        Vector3 tr = new Vector3((float)stabilizer.span / 2, 0, (float)stabilizer.chord / 2);
        Vector3 br = new Vector3((float)stabilizer.span / 2, 0, (float)-stabilizer.chord / 2);
        Vector3 bl = new Vector3((float)-stabilizer.span / 2, 0, (float)-stabilizer.chord / 2);

        Debug.DrawLine(transform.TransformPoint(tl), transform.TransformPoint(tr), Color.gray);
        Debug.DrawLine(transform.TransformPoint(tr), transform.TransformPoint(br), Color.gray);
        Debug.DrawLine(transform.TransformPoint(br), transform.TransformPoint(bl), Color.gray);
        Debug.DrawLine(transform.TransformPoint(bl), transform.TransformPoint(tl), Color.gray);
    }
Пример #5
0
        static Program()
        {
            DataReader = new DataReader(InputFileName);
            DataWriter = new DataWriter(OutputFolderPrefix, ParametersOutputFileName, DataWindowFileSuffix,
                                        DataIntervalsFileSuffix, OutputFileExtension);
            DataWindow           = new DataWindow(DataWindowSize);
            ParametersCalculator = new ParametersCalculator();
            Optimizer            = new Optimizer(Xi, Xs);
            var standardHi2Values = new StandardHi2Values(Precision);

            Stabilizer = new Stabilizer(standardHi2Values, NumberOfParameters);
            Calibrator = new Calibrator(Xi, Xs);
        }
Пример #6
0
 private Func <Variable, Function> CreateModel(int numOutputDimension, int numLstmLayer, int numHiddenDimension)
 {
     return((input) =>
     {
         Function model = input;
         for (int i = 0; i < numLstmLayer; i++)
         {
             model = Stabilizer.Build(model, device);
             model = LSTM.Build(model, numHiddenDimension, device);
         }
         model = Dense.Build(model, numOutputDimension, device);
         return model;
     });
 }
Пример #7
0
        protected override void Awake()
        {
            rigidbody = GetComponent <Rigidbody>();
            if (rigidbody != null)
            {
                rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
            }

            subroot    = gameObject.GetComponent <SubRoot>();
            control    = GetComponent <SubControl>();
            stabilizer = GetComponent <Stabilizer>();

            subTurnHandlers     = (ISubTurnHandler[])control.ReflectionGet("turnHandlers");
            subThrottleHandlers = (ISubThrottleHandler[])control.ReflectionGet("throttleHandlers");

            base.Awake();
        }
Пример #8
0
        public Program()
        {
            // ======== ======== ======== ======== ======== ======== ======== ========
            // SETUP
            // ======== ======== ======== ======== ======== ======== ======== ========
            // Speed of yaw rotation. Use 0.0f to lock.
            float YawSpeed = 0.5f;

            // ======== ======== ======== ======== ======== ======== ======== ========
            // END OF SETUP
            // ======== ======== ======== ======== ======== ======== ======== ========

            try {
                gStabilizer = new Stabilizer(this, YawSpeed);

                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }
            catch (Exception e) {
                Echo(e.Message);
            }
        }
Пример #9
0
    // Start is called before the first frame update
    void Start()
    {
        // Setup references to important components

        var bodyStabilizers = _body.GetComponents <Stabilizer>();

        _bodyStabilizer     = ((Stabilizer.Axes.Z == bodyStabilizers[0].StabilizationAxis) ? bodyStabilizers[1] : bodyStabilizers[0]);
        _bodyLookStabilizer = ((Stabilizer.Axes.Z == bodyStabilizers[0].StabilizationAxis) ? bodyStabilizers[0] : bodyStabilizers[1]);

        var headStabilizers = _head.GetComponents <Stabilizer>();

        _headStabilizer     = ((Stabilizer.Axes.Z == headStabilizers[0].StabilizationAxis) ? headStabilizers[1] : headStabilizers[0]);
        _headLookStabilizer = ((Stabilizer.Axes.Z == headStabilizers[0].StabilizationAxis) ? headStabilizers[0] : headStabilizers[1]);

        _neck = _head.GetComponent <DirectionalJoint>();

        // For testing purposes, any GameObject can be set as target, but by default it will be set to the player
        if (null == _target)
        {
            _target = FindObjectOfType <PlayerControls>().gameObject;
        }
    }
Пример #10
0
    public Worker(Program parent, string cockpit = "", string container = "", float yaw_speed = 0.5f)
    {
        Reroute console = new Reroute((gParent = parent));

        try {
            console.Compile("Battery");
            gBattery = new Battery(gParent);

            console.Compile("Payload");
            gPayload = new Payload(gParent, container);

            console.Compile("Stabilizer");
            gStabilizer = new Stabilizer(gParent, yaw_speed);

            console.Compile("Worker");

            // Get a cockpit:
            if (cockpit == string.Empty)
            {
                List <IMyCockpit> cockpitblocks = new List <IMyCockpit>();
                gParent.GridTerminalSystem.GetBlocksOfType(cockpitblocks, x => x.IsSameConstructAs(gParent.Me));
                if (cockpitblocks.Count == 0)
                {
                    throw new Exception("No cockpit found.");
                }
                else
                {
                    gCockpit = cockpitblocks[0];
                }
            }
            else
            {
                gCockpit = gParent.GridTerminalSystem.GetBlockWithName(cockpit) as IMyCockpit;
            }

            if (gCockpit == null || !gCockpit.IsSameConstructAs(gParent.Me))
            {
                throw new Exception($"No cockpit found with argument: '{cockpit}'");
            }

            // Set up text surfaces:
            lSurface = null;

            switch (gCockpit.BlockDefinition.SubtypeName)
            {
            case "SmallBlockCockpit":
            case "LargeBlockCockpitSeat":
                lSurface = new List <IMyTextSurface> {
                    gCockpit.GetSurface(0), gCockpit.GetSurface(1), gCockpit.GetSurface(2)
                };
                break;

            case "SmallBlockCockpitIndustrial":
                lSurface = new List <IMyTextSurface> {
                    gCockpit.GetSurface(1), gCockpit.GetSurface(0), gCockpit.GetSurface(2)
                };
                break;

            case "LargeBlockCockpitIndustrial":
                lSurface = new List <IMyTextSurface> {
                    gCockpit.GetSurface(2), gCockpit.GetSurface(1), gCockpit.GetSurface(3)
                };
                break;

            default:
                throw new Exception($"Cockpit '{gCockpit.CustomName}' is not a suitable cockpit.");
            }

            gParent.Echo($"Using cockpit: '{gCockpit.CustomName}'");

            foreach (IMyTextSurface s in lSurface)
            {
                s.Font        = "Debug";
                s.FontSize    = 3.0f;
                s.TextPadding = 20.0f;
                s.ContentType = ContentType.TEXT_AND_IMAGE;
                s.Alignment   = TextAlignment.CENTER;
            }

            if (gCockpit.BlockDefinition.SubtypeName == "SmallBlockCockpit")
            {
                lSurface[0].FontSize = 4.0f;
            }

            // Done:
            SetCargoScreen();
            SetStabilizerScreen(false);
            SetBatteryScreen();

            console.Report();

            gParent.Runtime.UpdateFrequency = UpdateFrequency.Update100;
        }
        catch (Exception e) {
            console.Cancel(e.Message);
        }
    }