コード例 #1
0
ファイル: Program.cs プロジェクト: TatianaPearl/Fractals
        private void PlotPoints(Options options)
        {
            var arguments = DeserializeArguments <PointPlottingArguments>(options.ConfigurationFilepath);
            var plotter   = new TrajectoryPlotter(arguments.InputDirectory, arguments.InputFilePattern, arguments.OutputDirectory, arguments.OutputFilename, arguments.Resolution.Width, arguments.Resolution.Height, arguments.Bailout);

            plotter.Plot();
        }
コード例 #2
0
 private void Awake()
 {
     trajectoryPlotter   = GetComponent <TrajectoryPlotter>();
     sourceIntersections = new List <SourceIntersections>();
     // Initialize source intersection colors
     // FIXME THIS IS TEMPORARY
     sourceIntersectionColors = new List <Color>
     {
         Color.red,
         Color.green,
         Color.blue
     };
     sourceIntersectionColorCount = sourceIntersectionColors.Count;
 }
コード例 #3
0
ファイル: TrajectoryHandler.cs プロジェクト: rtoole13/Orbital
    private void Awake()
    {
        orbitalBody = GetComponent <OrbitalBody>();
        orbitalBody.OnOrbitCalculationEvent += UpdateTrajectory;

        // Instantiate prefab if null
        trajectoryObject  = Instantiate(trajectoryObjectPrefab);
        trajectoryPlotter = trajectoryObject.GetComponent <TrajectoryPlotter>();
        if (trajectoryPlotter == null)
        {
            throw new UnityException("Expecting trajectory prefab to have a TrajectoryPlotter script");
        }
        trajectoryPlotter.SetGradient(trajectoryGradient);
        intersectionCalculator = trajectoryObject.GetComponent <IntersectionCalculator>();
    }
コード例 #4
0
    private void UpdateOrbit()
    {
        if (DeltaVelocity.magnitude < minimumDeltaVelocity)
        {
            return;
        }

        if (trajectoryObjectPrefab == null)
        {
            Debug.Log("No trajectory object prefab selected!");
            return;
        }

        if (trajectoryObject == null)
        {
            // Instantiate prefab if null
            trajectoryObject  = Instantiate(trajectoryObjectPrefab);
            trajectoryPlotter = trajectoryObject.GetComponent <TrajectoryPlotter>();

            // Pass ship to intersection calculator
            intersectionCalculator = trajectoryObject.GetComponent <IntersectionCalculator>();
            //intersectionCalculator.SetOrbitalBody(ship);
        }
        trajectoryObject.transform.parent   = ship.CurrentGravitySource.transform;
        trajectoryObject.transform.position = trajectoryObject.transform.parent.position;

        // Specifically velocity in world coordinates!
        Vector2 newOrbitalVelocity = orbitalSpeed * orbitalDirection + DeltaVelocity;
        Vector2 relVel             = newOrbitalVelocity.RotateVector(ship.Trajectory.ArgumentOfPeriapsis);
        Vector2 relPos             = (Vector2)transform.position - ship.CurrentGravitySource.Position; // world pos - newSource.pos

        trajectory.CalculateOrbitalParametersFromStateVectors(relPos, relVel, ship.CurrentGravitySource);
        if (trajectory.TrajectoryType == Mechanics.Globals.TrajectoryType.Ellipse)
        {
            trajectoryPlotter.BuildEllipticalTrajectory(trajectory.SemimajorAxis, trajectory.SemiminorAxis, trajectory.Eccentricity, trajectory.ArgumentOfPeriapsis);
        }
        else
        {
            trajectoryPlotter.BuildHyperbolicTrajectory(trajectory.SemimajorAxis, trajectory.SemiminorAxis, trajectory.Eccentricity, trajectory.ArgumentOfPeriapsis);
        }
        float timeToNode = OrbitalMechanics.UniversalVariableMethod.CalculateTimeOfFlight(ship.OrbitalPosition, ship.OrbitalVelocity, orbitalPosition, ship.Trajectory.EccentricityVector, ship.Trajectory.ParentGravitySource.Mass);

        UpdateIntersections(timeToNode, relPos, relVel);
    }