示例#1
0
        public static List <AccountStats> AddAcountStats(List <TradeRecord> trades, int accountNumber, int leverage)
        {
            var dailyNavs        = unitOfWork.DailyNAVRepository.GetAll().Where(x => x.AccountNumber == accountNumber).FirstOrDefault();
            var AccountStatsList = new List <AccountStats>();

            for (int i = 1; i <= 44; i++)
            {
                AccountStats accountStats = new AccountStats();
                accountStats.AccountId  = i.ToString();
                accountStats.Balance    = MathCalculations.GenerateRandomNo(6);
                accountStats.BestPL     = CalculateBestPLForTimeline(i, trades);
                accountStats.CreatedBy  = MathCalculations.GenerateRandomNo(2);
                accountStats.Leverage   = leverage;
                accountStats.CreatedOn  = DateTime.UtcNow.ToString();
                accountStats.DD         = dailyNavs == null ? 0 : CalculateDDForTimeline(i, dailyNavs);
                accountStats.NAV        = dailyNavs == null ? 0 : CalculateNavForTimeline(i, dailyNavs); //Math.Round(dailyNavs.NAVByDate[dailyNavs.NAVByDate.Count - 1].NAV, 2);
                accountStats.ROI        = dailyNavs == null ? 0 : CalculateROIForTimeline(i, dailyNavs, trades);
                accountStats.SharpRatio = dailyNavs == null ? 0 : CalculateSharpRatioForTimeline(i, dailyNavs);
                accountStats.Status     = true;
                accountStats.TimeLineId = i;
                //accountStats.UpdatedBy = MathCalculations.GenerateRandomNo(2);
                //accountStats.UpdatedOn = GenerateRandomDate();
                accountStats.WINRate = CalculateWINForTimeline(i, trades);
                accountStats.WorstPL = CalculateWorstPLForTimeline(i, trades);

                //_unitOfWork.AccountStatsRepository.Add(accountStats);
                AccountStatsList.Add(accountStats);
            }

            return(AccountStatsList);
        }
示例#2
0
 private void TankMovement()
 {
     if (MathCalculations.Distance(new Coords(this.transform.position), new Coords(fuel.transform.position)) > stoppingDist)
     {
         this.transform.position += direction * speed * Time.deltaTime;
     }
 }
示例#3
0
        public static List <InstrumentStats> AddInstrumentStats(string name, List <TradeRecord> trades)
        {
            var instrumentName   = trades.Where(x => x.Cmd == TradeCommand.Buy || x.Cmd == TradeCommand.Sell).Select(x => x.Symbol).Distinct().ToList();
            var AccountStatsList = new List <InstrumentStats>();

            foreach (TimeLineEnum timeline in Enum.GetValues(typeof(TimeLineEnum)))
            {
                foreach (var item in instrumentName.Select((Value, Index) => new { Value, Index }))
                {
                    InstrumentStats instrumentStats = new InstrumentStats();
                    instrumentStats.TimeLineId     = (int)timeline;
                    instrumentStats.AccountStatsId = timeline;
                    instrumentStats.BuyRate        = MathCalculations.GenerateRandomNo(3);
                    instrumentStats.CreatedBy      = name;
                    //accountStats.CreatedOn = GenerateRandomDate();
                    instrumentStats.InstrumentId   = item.Index + 1;
                    instrumentStats.InstrumentName = item.Value;
                    instrumentStats.Volume         = InstrumentsCalculations.GetVolumeOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                    instrumentStats.WINRate        = MathCalculations.GenerateRandomNo(2);
                    instrumentStats.NAV            = MathCalculations.GenerateRandomNo(2);
                    instrumentStats.ROI            = MathCalculations.GenerateRandomNo(2);
                    instrumentStats.Profit         = InstrumentsCalculations.GetProfitOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                    instrumentStats.Loss           = InstrumentsCalculations.GetLossOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                    instrumentStats.Status         = true;
                    if (instrumentStats.Volume > 0)
                    {
                        AccountStatsList.Add(instrumentStats);
                    }
                }
            }

            return(AccountStatsList);
        }
示例#4
0
 /****************************************************************
 * Name - Subroutine GETTAR
 * Purpose - Provides a moving target.
 * Variables -
 * NAME TYPE UNITS
 *------------------------------------------------------------
 * TARX REAL earth-based X
 * TARY REAL earth-based Y
 * TARZ REAL earth-based Z
 * ITMIN INTEGER (# of iterations per second)
 ****************************************************************/
 private void Gettar(ref float tarx, ref float tary, ref float tarz, GameObject targetObject)
 {
     //  float mach = 234.375f;
     tarx = MathCalculations.ConvertUnityToMeters(targetObject.transform.localPosition.x, false);
     tary = MathCalculations.ConvertUnityToMeters(targetObject.transform.localPosition.y, true);
     tarz = MathCalculations.ConvertUnityToMeters(targetObject.transform.localPosition.z, true);
 }
示例#5
0
        public List <AccountStats> AddDummyAcountStats(string name)
        {
            var AccountStatsList = new List <AccountStats>();

            for (int i = 1; i <= 45; i++)
            {
                AccountStats accountStats = new AccountStats();

                accountStats.AccountId       = i.ToString();
                accountStats.StatringBalance = MathCalculations.GenerateRandomNo(6);
                accountStats.BestPL          = MathCalculations.GenerateRandomNo(4).ToString();
                accountStats.CreatedBy       = name;
                accountStats.Leverage        = i;
                accountStats.CreatedOn       = GenerateRandomDate();
                accountStats.DD         = MathCalculations.GenerateRandomNo(3);
                accountStats.NAV        = MathCalculations.GenerateRandomNo(3);
                accountStats.ROI        = MathCalculations.GenerateRandomNo(3);
                accountStats.SharpRatio = MathCalculations.GenerateRandomNo(6);
                accountStats.Status     = true;
                //accountStats.DD =  MathCalculations.GenerateRandomNo(2);
                accountStats.TimeLineId = i;
                accountStats.UpdatedBy  = MathCalculations.GenerateRandomNo(2);
                accountStats.UpdatedOn  = GenerateRandomDate();
                accountStats.WINRate    = MathCalculations.GenerateRandomNo(3);
                accountStats.WorstPL    = MathCalculations.GenerateRandomNo(2).ToString();

                //_unitOfWork.AccountStatsRepository.Add(accountStats);
                AccountStatsList.Add(accountStats);
            }

            return(AccountStatsList);
        }
示例#6
0
        public AuthenticationResponse GenerateOTP(string email, string password)
        {
            var OTP  = MathCalculations.GenerateRandomNo(6).ToString();
            var user = _unitOfWork.UserRepository.GetAll().Where(m => m.EmailID == email.Trim()).FirstOrDefault();

            if (user != null)
            {
                var isLogin = CommonFunction.ComparePassword(password, user.Password);
                if (isLogin)
                {
                    user.OTP = OTP;
                    _unitOfWork.UserRepository.Update(user);
                    var isSent = this.SendOTPEmail(user);
                    if (isSent)
                    {
                        return(new AuthenticationResponse {
                            Success = true, Message = CommonMessage.SentOTP
                        });
                    }
                }
            }
            return(new AuthenticationResponse {
                Message = ErrorMessage.Invalid_Credentials, Success = false
            });
        }
示例#7
0
    public void SetVelocityPerSecond(float velocity)
    {
        _velocity          = velocity;
        totalTerrainLength = MathCalculations.MaxBounds()[0];

        delta = (_velocity / totalTerrainLength) * 2f;
    }
示例#8
0
    // Update is called once per frame
    void Update()
    {
        float tometer = MathCalculations.ConvertFeettoMeter(alt);
        float topixel = MathCalculations.ConvertFeettoMeter(tometer);

        Debug.Log(topixel);
        //this.transform.position = new Vector3(0, topixel, 0);
    }
示例#9
0
    public void GetLatLongFromHmVm(float horizontalMove, float verticalMove)
    {
        //Convert value on scale of 0 to 2 to Actual resolution
        float x = (horizontalMove / 2f) * maximumX;
        float y = (verticalMove / 2f) * maximumY;

        //Generate LatLong from the gained value
        LatLong = MathCalculations.XYtoLatLong(x, y);
    }
    void Update()
    {
        //Increace angle
        m_angle += m_speed * Time.deltaTime;


        //Set satellite position
        m_satellite.localPosition = MathCalculations.GetDirectionByAngle(m_distance, m_angle);
    }
示例#11
0
 private static List <InstrumentStats> AddInstrumentStatsForExistingUsers(string name, List <TradeRecord> trades, List <InstrumentStats> Instruments)
 {
     try
     {
         var instrumentName      = trades.Where(x => x.Cmd == TradeCommand.Buy || x.Cmd == TradeCommand.Sell).Select(x => x.Symbol).Distinct().ToList();
         var existingInstruments = Instruments.Select(x => x.InstrumentName).Distinct().ToList();
         var newInstruments      = trades.Where(x => (x.Cmd == TradeCommand.Buy || x.Cmd == TradeCommand.Sell) && !existingInstruments.Contains(x.Symbol)).Select(x => x.Symbol).Distinct().ToList();
         var timelineIds         = GetTimelinesForExistingUser();
         foreach (var timeline in timelineIds)
         {
             foreach (var item in existingInstruments.Select((Value, Index) => new { Value, Index }))
             {
                 InstrumentStats existinInstrument = Instruments.Where(x => x.InstrumentName == item.Value && x.TimeLineId == (int)timeline).FirstOrDefault();
                 if (existinInstrument != null)
                 {
                     existinInstrument.Volume = InstrumentsCalculations.GetVolumeOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     existinInstrument.Profit = InstrumentsCalculations.GetProfitOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     existinInstrument.Loss   = InstrumentsCalculations.GetLossOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                 }
             }
         }
         if (newInstruments.Count > 0)
         {
             foreach (TimeLineEnum timeline in Enum.GetValues(typeof(TimeLineEnum)))
             {
                 foreach (var item in newInstruments.Select((Value, Index) => new { Value, Index }))
                 {
                     InstrumentStats instrumentStats = new InstrumentStats();
                     instrumentStats.TimeLineId     = (int)timeline;
                     instrumentStats.AccountStatsId = timeline;
                     instrumentStats.BuyRate        = MathCalculations.GenerateRandomNo(3);
                     instrumentStats.CreatedBy      = name;
                     //accountStats.CreatedOn = GenerateRandomDate();
                     instrumentStats.InstrumentId   = item.Index + 1;
                     instrumentStats.InstrumentName = item.Value;
                     instrumentStats.Volume         = InstrumentsCalculations.GetVolumeOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     instrumentStats.WINRate        = MathCalculations.GenerateRandomNo(2);
                     instrumentStats.NAV            = MathCalculations.GenerateRandomNo(2);
                     instrumentStats.ROI            = MathCalculations.GenerateRandomNo(2);
                     instrumentStats.Profit         = InstrumentsCalculations.GetProfitOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     instrumentStats.Loss           = InstrumentsCalculations.GetLossOfInstrumentByTimelineId((int)timeline, trades, item.Value);
                     instrumentStats.Status         = true;
                     if (instrumentStats.Volume > 0)
                     {
                         Instruments.Add(instrumentStats);
                     }
                 }
             }
         }
         return(Instruments);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#12
0
    public void setInitialpos()
    {
        altitude = alldata[0][3];
        float[] xzy = MathCalculations.Convert(alldata[0][1], alldata[0][2], alldata[0][3]); //lat long

        //MathCalculations.DistanceToLatlong(new Vector2(xzy[0], xzy[1]));
        x = xzy[0];
        z = xzy[1];
        //maxheight = y;
        y = xzy[2];
        targetPosition          = new Vector3(x, y, z);
        transform.localPosition = targetPosition;

        //This is correct and verified
        roll                    = alldata[0][4];
        pitch                   = alldata[0][5];
        heading                 = alldata[0][6];
        speed                   = alldata[0][11];
        targetRotation          = Quaternion.Euler(pitch, heading, -roll); //roll and heading are swapped
        transform.localRotation = targetRotation;

        startPosition   = targetPosition = gameObject.transform.localPosition;
        startRotation   = targetRotation = transform.localRotation;
        initialPosition = transform.position;

        t1 = alldata[0][0];

        //Debug.Log("Time T1"+ t1);
        //Add Time Offset to start time
        //int offset = (type == "F7") ? 8 : 0;
        //		hr = GameObject.Find("StartTimeManager").GetComponent<EditStartTime>().hrs.ToString();
        //		min = GameObject.Find ("StartTimeManager").GetComponent<EditStartTime> ().mins.ToString();
        //		sec = GameObject.Find ("StartTimeManager").GetComponent<EditStartTime> ().secs.ToString();
        //
        //		updatedStartTime = hr + ":" + min + ":" + sec;
        //Debug.Log ("Updated Time From UI From AddMission Scene = " + updatedStartTime);

        localtime = MathCalculations.ConvertTime(t1, offset);

        //        hr = PlayerPrefs.GetFloat("StartHour").ToString();
        //		min = PlayerPrefs.GetFloat("StartMinute").ToString();
        //		sec = PlayerPrefs.GetFloat("StartSecond").ToString();
        //UnityEngine.Debug.Log("list values" + TailIDElements);

        //starttime = updatedStartTime;
        starttime = localtime;
        //Debug.Log("Starttime after mathcalculation = "+ starttime);

        endtime = MathCalculations.ConvertTime(alldata[alldata.Count - 1][0], offset);

        //dashboardData = alldata[counterAllData];
        counterAllData = 1;
        //time.GetComponent<TextMesh>().text = "Local Time:\n" + localtime;
        planeInfo.GetComponent <TextMesh>().text = "Callsign: " + callsign + "\nTailID: " + tailID + "\nAltitude: " + altitude.ToString() + "ft\nHeading: " + heading.ToString() + "\nSpeed: " + speed.ToString() + "kn";
    }
示例#13
0
        private double[,] applyRotationAroundZ(double angle)
        {
            double[,] rotation = new double[3, 3];
            rotation[2, 2]     = 1;
            double radians = MathCalculations.DegreeToRad(angle);

            rotation[0, 0] = Math.Cos(radians);
            rotation[0, 1] = Math.Sin(radians);
            rotation[1, 0] = -Math.Sin(radians);
            rotation[1, 1] = Math.Cos(radians);
            return(rotation);
        }
示例#14
0
    public void ExtractData(string filepath)
    {
        string[] text = File.ReadAllText(filepath).Split('\n');
        //Debug.Log(filepath);
        text = text.Skip(3).ToArray();
        //Debug.Log(text[0]);
        alldata.Clear();

        foreach (var item in text)
        {
            //Debug.Log(item);
            if (!(item == ""))
            {
                string[]     datapoints = item.Split('\t');
                List <float> rdata      = new List <float>();
                int          maxFields  = 0;
                foreach (var datapoint in datapoints)
                {
                    float num1;
                    bool  res = float.TryParse(datapoint, out num1);
                    if (res)
                    {
                        rdata.Add(float.Parse(datapoint));
                        maxFields++;

                        if (maxFields >= 12)
                        {
                            break;
                        }
                    }
                }

                if (rdata[11] >= 100)
                {
                    alldata.Add(rdata);
                }
            }
        }

        //Etime = alldata[alldata.Count-1][0];
        for (int i = 0; i < alldata.Count; i++)
        {
            Stime     = MathCalculations.ConvertTime(alldata[0][0]);
            Etime     = MathCalculations.ConvertTime(alldata[i][0]);
            leftlat   = Math.Min(leftlat, alldata[i][1]);
            leftlong  = Math.Min(leftlong, alldata[i][2]);
            rightlat  = Math.Max(rightlat, alldata[i][1]);
            rightlong = Math.Max(rightlong, alldata[i][2]);
        }
        Debug.Log(filepath + " starttime " + Stime + " endtime " + Etime);
    }
示例#15
0
    public void DoBullEyeCalculation()
    {
        float altitude = 1000;

        float[] xzy = MathCalculations.Convert(LatLong.x, LatLong.y, altitude); //lat long

        float x = xzy[0];
        float z = xzy[1];

        //float y = xzy[2];
        targetPosition = new Vector3(x, 0, z);

        bullsEyeObject.GetComponent <PositionData>().SetLatLong(LatLong);
    }
示例#16
0
    public void RecieveData()
    {
        Byte[] recData = receivingUdpClient.Receive(ref RemoteIpEndPoint);

        ACMIdata liveData = new ACMIdata();

        if (recData.Length == 289)
        {
            liveData.Time         = BitConverter.ToSingle(recData, 5);
            liveData.TailID       = BitConverter.ToInt32(recData, 9);
            liveData.AircraftType = BitConverter.ToInt32(recData, 13);
            liveData.Latitude     = BitConverter.ToSingle(recData, 17);
            liveData.Longitude    = BitConverter.ToSingle(recData, 21);
            liveData.Altitude     = BitConverter.ToSingle(recData, 25);
            liveData.Roll         = BitConverter.ToSingle(recData, 29);
            liveData.Pitch        = BitConverter.ToSingle(recData, 33);
            liveData.Heading      = BitConverter.ToSingle(recData, 37);
            liveData.MachNo       = BitConverter.ToSingle(recData, 41);
            liveData.Speed        = BitConverter.ToSingle(recData, 45);
            liveData.G            = BitConverter.ToSingle(recData, 49);
            liveData.Aoa          = BitConverter.ToSingle(recData, 53);

            //Debug.Log("<<<<<<<<<<<<<<<<<<<<<<<DATA PACKET>>>>>>>>>>>>>>>>>>>>>\n");
            //Debug.Log("Time:\t\t" + MathCalculations.ConvertTime(liveData.Time));

            //Debug.Log("Tail ID:\t\t" + liveData.TailID);
            //Debug.Log("Aircraft Type:\t\t " + liveData.AircraftType);
            //Debug.Log("Latitude:\t\t" + liveData.Latitude);
            //Debug.Log("Longitude:\t\t" + liveData.Longitude);
            //Debug.Log("Altitude:\t\t" + liveData.Altitude);
            //Debug.Log("Roll:\t\t" + liveData.Roll);
            //Debug.Log("Pitch:\t\t" + liveData.Pitch);
            //Debug.Log("Heading:\t\t" + liveData.Heading);
            //Debug.Log("Mach No:\t\t" + liveData.MachNo);
            //Debug.Log("Speed:\t\t" + liveData.Speed);
            //Debug.Log("G:\t\t" + liveData.G);
            //Debug.Log("Aoa:\t\t" + liveData.Aoa);
            //Debug.Log("<<<<<<<<<<<<<<<<<<<<<<<DATA PACKET>>>>>>>>>>>>>>>>>>>>>\n");

            //DICTIONARY KA KAM
            var key = liveData.TailID;
            liveDataPackets[key] = liveData;


            ExecuteEvents.Execute <IliveDataRecieved>(GameObject.Find("LiveDataManager"), null, (x, y) => x.liveDataRecieved(liveDataPackets[key]));
            localTimeText.text = MathCalculations.ConvertTime(liveDataPackets[key].Time);
        }
    }
示例#17
0
    private List <float> ConvertToXYForBullsEye(List <float> attributes)
    {
        List <float> convertedAttributes = new List <float>();

        double altitude = 1000;

        float[] p1        = MathCalculations.Convert(attributes[0], attributes[1], altitude); //lat long
        float   latitude  = p1[0];
        float   longitude = p1[1];

        convertedAttributes.Add(latitude);
        convertedAttributes.Add(longitude);
        convertedAttributes.Add(attributes[2]);


        return(convertedAttributes);
    }
示例#18
0
    private void Start()
    {
        //  currentLocation = this.transform.position;
        direction = fuel.transform.position - this.transform.position;
        Coords dirNormal = MathCalculations.GetNormal(new Coords(direction));

        direction = dirNormal.ToVector();

        float angle = MathCalculations.Angle(new Coords(0, 1, 0), new Coords(direction)) * 180.0f / Mathf.PI;

        Debug.Log("Angle to fuel = " + angle);

        //float angle1 = MathCalculations.Angle(new Coords(0, -2, 0), new Coords(-1, 2, 0)) * 180.0f / Mathf.PI;

        //float angle2 = MathCalculations.Angle(new Coords(0, -2, 0), new Coords(1, 2, 0)) * 180.0f / Mathf.PI;
        //Debug.Log("_____" + angle1);
        //Debug.Log("_____" + angle2);
    }
示例#19
0
        public List <InstrumentStats> AddInstrumentStats(string name)
        {
            var instrumentName = new List <string> {
                "EUR/USD", "GBP/SGD", "SGD/AUD"
            }.ToList();
            var timeLine = new List <int> {
                1, 2, 3
            }.ToList();

            var AccountStatsList = new List <InstrumentStats>();

            int count = 11;

            for (int i = 1; i <= 45; i++)
            {
                foreach (var item in instrumentName.Select((Value, Index) => new { Value, Index }))
                {
                    InstrumentStats accountStats = new InstrumentStats();

                    accountStats.AccountStatsId = i.ToString();
                    accountStats.BuyRate        = MathCalculations.GenerateRandomNo(3);
                    accountStats.CreatedBy      = name;
                    accountStats.CreatedOn      = GenerateRandomDate();
                    accountStats.InstrumentId   = item.Index + 1;
                    //InstrumentMasterEnum.EURUSD.ToString();
                    accountStats.Volume  = MathCalculations.GenerateRandomNo(2);
                    accountStats.WINRate = MathCalculations.GenerateRandomNo(2);
                    accountStats.NAV     = MathCalculations.GenerateRandomNo(2);
                    accountStats.ROI     = MathCalculations.GenerateRandomNo(2);
                    accountStats.Status  = false;

                    accountStats.TimeLineId = i;
                    accountStats.UpdatedBy  = name;
                    accountStats.UpdatedOn  = GenerateRandomDate();
                    AccountStatsList.Add(accountStats);

                    ++count;
                }
            }

            return(AccountStatsList);
        }
示例#20
0
    public void SetAircraftsPosition(LiveAcmiDataReciever.ACMIdata liveData, GameObject aircraft)
    {
        float[] xzy = MathCalculations.Convert(liveData.Latitude, liveData.Longitude, liveData.Altitude);

        float x = xzy[0];
        float z = xzy[1];
        float y = xzy[2];

        updatedPosition = new Vector3(x, y, z);
        aircraft.transform.localPosition = updatedPosition;


        float roll    = liveData.Roll;
        float pitch   = liveData.Pitch;
        float heading = liveData.Heading;

        heading         = heading - 180;
        updatedRotation = Quaternion.Euler(pitch, heading, -roll);
        aircraft.transform.localRotation = updatedRotation;
    }
        public List <InvoiceModel> DownloadInvoice(string userId, List <Guid> invoiceIds)
        {
            var user = _unitOfWork.UserRepository.GetAll().Where(x => x.Id == ObjectId.Parse(userId)).FirstOrDefault();

            if (user != null)
            {
                if (user.UserInvoiceHistory == null)
                {
                    return(null);
                }

                var invoiceHistoryForInvoice = user.UserInvoiceHistory.Where(x => invoiceIds.Contains(x.Id)).ToList();
                //if (invoiceHistoryForInvoice == null || invoiceHistoryForInvoice.Count == 0) { return null; }
                var accounts = _unitOfWork.AccountDetailRepository.GetAll().Where(x => x.OrganizationId == user.OrganizationID).Count();

                List <InvoiceModel> invoiceModelList;
                invoiceModelList = invoiceHistoryForInvoice.Select(x => new InvoiceModel
                {
                    InvoiceNumber  = MathCalculations.GenerateRandomNo(8).ToString(),
                    Country        = user.Country,
                    EmailId        = user.EmailID,
                    InvoiceDate    = (DateTime.UtcNow).ToString("dd/MM/yyyy"),
                    ClientName     = user.Name,
                    PlanName       = x.PlanName,
                    PlanLogo       = x.PlanId == 2 ? "basic.png" : x.PlanId == 3 ? "advance.png" : "ultimate.png",
                    Price          = (x.Price + x.UsedUserCreditAmount).ToString(),
                    TotalAccounts  = accounts.ToString(),
                    ApplicationFee = x.ApplicationFee.ToString(),
                    SubTotal       = Math.Round((x.Price)).ToString(),
                    Total          = (Math.Round((x.Price)) + x.ApplicationFee).ToString(),
                    CreditedAmount = x.UsedUserCreditAmount.ToString()
                }).ToList();


                return(invoiceModelList);
            }
            else
            {
                return(null);
            }
        }
示例#22
0
    private float GetHitProbability(GameObject ownShip, GameObject target, double missileRange)
    {
        double totalTerrainLength = MathCalculations.MaxBounds()[0];

        float missileUnityUnits = (float)(missileRange / totalTerrainLength) * 2f;
        float distance          = Vector3.Distance(ownShip.transform.position, target.transform.position);

        if (distance <= missileUnityUnits)
        {
            Vector3 targetDir = target.transform.position - ownShip.transform.position;
            float   angle     = Vector3.Angle(targetDir, ownShip.transform.forward);

            //Is in semi sphere cone
            if (angle > 90f)
            {
                float directionalProbability = angle / 180f;
                float distanceProbability    = 1 - (distance / missileUnityUnits);
                return(distanceProbability * directionalProbability);
            }
        }
        return(0f);
    }
示例#23
0
    public void SetCurrentPosition(int positionId)
    {
        altitude = alldata[positionId][3];
        float[] xzy = MathCalculations.Convert(alldata[positionId][1], alldata[positionId][2], alldata[positionId][3]); //lat long
        x = xzy[0];
        z = xzy[1];
        //maxheight = y;
        y = xzy[2];
        targetPosition          = new Vector3(x, y, z);
        transform.localPosition = targetPosition;

        //This is correct and verified
        roll                    = alldata[positionId][4];
        pitch                   = alldata[positionId][5];
        heading                 = alldata[positionId][6];
        speed                   = alldata[positionId][11];
        targetRotation          = Quaternion.Euler(pitch, heading, -roll); //roll and heading are swapped
        transform.localRotation = targetRotation;

        startPosition = targetPosition = gameObject.transform.localPosition;
        startRotation = targetRotation = transform.localRotation;


        t1 = alldata[positionId][0];

        //Add Time Offset to start time
        int offset = (type == "F7") ? 8 : 0;

        localtime = MathCalculations.ConvertTime(t1, offset);



        //dashboardData = alldata[counterAllData];
        counterAllData = positionId + 1;
        //time.GetComponent<TextMesh>().text = "Local Time:\n" + localtime;
        planeInfo.GetComponent <TextMesh>().text = "Callsign: " + callsign + "\nTailID: " + tailID + "\nAltitude: " + altitude.ToString() + "ft\nHeading: " + heading.ToString() + "\nSpeed: " + speed.ToString() + "kn";
    }
示例#24
0
    private List <float> ConvertToXY(List <float> attributes)
    {
        List <float> convertedAttributes = new List <float>();

        double altitude = 1000;

        float[] start   = MathCalculations.Convert(attributes[4], attributes[2], altitude); //lat long
        float   startX4 = start[0];
        float   startY2 = start[1];


        float[] end   = MathCalculations.Convert(attributes[5], attributes[3], altitude); //lat long
        float   endX5 = end[0];
        float   endY3 = end[1];

        convertedAttributes.Add(attributes[0]);
        convertedAttributes.Add(attributes[1]);
        convertedAttributes.Add(startY2);
        convertedAttributes.Add(endY3);
        convertedAttributes.Add(startX4);
        convertedAttributes.Add(endX5);

        return(convertedAttributes);
    }
示例#25
0
    static void Main()
    {
        try
        {
            var subString = MathCalculations.Subsequence("Hello!".ToCharArray(), 2, 3);
            Console.WriteLine(subString);

            var subArray = MathCalculations.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2);
            Console.WriteLine(String.Join(" ", subArray));

            var allArray = MathCalculations.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4);
            Console.WriteLine(String.Join(" ", allArray));

            var emptyArray = MathCalculations.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0);
            Console.WriteLine(String.Join(" ", emptyArray));
        }
        catch (ArgumentException ex)
        {
            Console.WriteLine(ex.Message);
        }

        try
        {
            Console.WriteLine(StringManipulations.ExtractEnding("I love C#", 2));
            Console.WriteLine(StringManipulations.ExtractEnding("Nakov", 4));
            Console.WriteLine(StringManipulations.ExtractEnding("beer", 4));
            Console.WriteLine(StringManipulations.ExtractEnding("Hi", 100));
        }
        catch (ArgumentOutOfRangeException ex)
        {
            Console.WriteLine(ex.Message);
        }

        // The app should not throw exceptions when checking whether number is prime.
        var numbers = new int[] { 23, 33 };

        foreach (var number in numbers)
        {
            bool isPrime = MathCalculations.CheckPrime(number);

            if (isPrime)
            {
                Console.WriteLine($"{number} is prime!");
            }
            else
            {
                Console.WriteLine($"{number} is not prime!");
            }
        }

        List <Exam> peterExams = new List <Exam>()
        {
            new SimpleMathExam(2),
            new CSharpExam(55),
            new CSharpExam(100),
            new SimpleMathExam(1),
            new CSharpExam(0),
        };

        Student peter = new Student("Peter", "Petrov", peterExams);
        double  peterAverageResult = peter.CalcAverageExamResultInPercents();

        Console.WriteLine("Average results = {0:p0}", peterAverageResult);
    }
示例#26
0
        public void AddDummyAcountDetails(Guid orgID)
        {
            var countries = new List <string> {
                "AU", "AU", "AU", "AU", "IN", "IN", "IN", "IN", "US", "US", "US", "US"
            };
            var userGroup = new List <string> {
                "AUS_GROUP", "AUS_GROUP", "AUS_GROUP", "AUS_GROUP", "IND_GROUP", "IND_GROUP", "IND_GROUP", "IND_GROUP", "US_GROUP", "US_GROUP", "US_GROUP", "US_GROUP"
            };
            var names = new List <string> {
                "Aadesh", "Aadarsh", "Aadhishankar", "Aadit", "Aagman", "Aagney", "Aahva", "Aakarshan", "Abhay", "Abhi", "Abhijat", "Abhijit", "Abhik", "Abhilash", "Abhinandan", "Abhinav", "Abhinivesh", "Abhiram", "Abhiroop", "Abhirut", "Abhisar", "Abhishek", "Abhyas", "Achal", "Achalraj"
            };
            var cities = new List <string> {
                "Melbourne", "Melbourne", "Brisbane", "Brisbane", "Mumbai", "Mumbai", "Chandigarh", "Chandigarh", "California", "California", "NewYork", "NewYork"
            };
            int count      = 12;
            int timeLineId = 2;//Year

            foreach (var item in countries.Select((Value, Index) => new { Value, Index }))
            {
                AccountDetail account = new AccountDetail();
                account.AccountNumber  = MathCalculations.GenerateRandomNo(6).ToString();
                account.Balance        = MathCalculations.GenerateRandomNo(6);
                account.OrganizationId = orgID;
                //account.DataSourceId = 1;
                account.Name         = names[item.Index];     //it's diff  each time
                account.Country      = item.Value;            //it's same 4 Times
                account.City         = cities[item.Index];    //it's same 2 times
                account.UserGroup    = userGroup[item.Index]; //it's same 4 Times
                account.AccountStats = AddDummyAcountStats(names[item.Index]);

                account.Leverage = MathCalculations.GenerateRandomNo(2);
                if (item.Index > 3)
                {
                    timeLineId = 7;//"1 Week (Current Week)
                }
                if (item.Index > 7)
                {
                    timeLineId = 5;// 1 Month(Current Calender Month)
                }
                //account.InstrumentStats = AddInstrumentStats(timeLineId);
                account.InstrumentStats = AddInstrumentStats(names[item.Index]);

                account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
                _unitOfWork.AccountDetailRepository.Add(account);
                count++;
            }

            //account = new AccountDetail();
            //account.AccountNumber = 2222;
            //account.Balance= 2222;
            //account.OrganizationId = new Guid("d5cc177f-5293-6247-bed7-838438c810a3");
            //account.DataSourceId = "2";
            //account.Name = "Shakeel";
            //account.Leverage = "2:50";
            //account.Country = "AUS";
            //account.City= "Ropar";
            //account.UserGroup = "AUS_1";
            //account.AccountStats = AddDummyAcountStats();
            //account.InstrumentStats = AddInstrumentStats();
            //account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
            //_unitOfWork.AccountDetailRepository.Add(account);

            //account = new AccountDetail();
            //account.AccountNumber = 3333;
            //account.Balance= 3333;
            //account.OrganizationId = new Guid("d5cc177f-5293-6247-bed7-838438c810a3");
            //account.DataSourceId = "1";
            //account.Name = "Mohit";
            //account.Leverage = "5:50";
            //account.Country = "IN";
            //account.City = "Melbourne";
            //account.UserGroup = "IN_1";
            //account.AccountStats = AddDummyAcountStats();
            //account.InstrumentStats = AddInstrumentStats();
            //account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
            //_unitOfWork.AccountDetailRepository.Add(account);

            //account = new AccountDetail();
            //account.AccountNumber = 4444;
            //account.Balance= 4444;
            //account.OrganizationId = new Guid("d5cc177f-5293-6247-bed7-838438c810a3");
            //account.DataSourceId = "4";
            //account.Name = "Aeby";
            //account.Leverage = "4:50";
            //account.Country = "AUS";
            //account.City = "New York";
            //account.UserGroup = "AUS_2";
            //account.AccountStats = AddDummyAcountStats();
            //account.InstrumentStats = AddInstrumentStats();
            //account.AccountTransactionHistories = AddAccountTransactionHistoryStats();
            //_unitOfWork.AccountDetailRepository.Add(account);

            // AddDummyTimeLine();
        }
示例#27
0
    public bool CalculateIsTargetHit(GameObject ownShip, GameObject targetAircraft, MissileData missileData, ref float probability)
    {
        probability = GetHitProbability(ownShip.transform.GetChild(0).gameObject, targetAircraft.transform.GetChild(0).gameObject, missileData.Range);
        ExtractConstantsFromMissileData(missileData);
        Vector3 ownerPosition  = ownShip.transform.localPosition;
        Vector3 ownerDirection = ownShip.transform.localRotation.eulerAngles;
        //Velocity, Pitch Rate, Yaw Rate, Pitch and Yaw
        float velcty, pitchr, yawr, pitch, yaw;
        //Position of missile, weight of missile, range (distance of missile and target)
        //Get this value from data table
        float x, y, z, range;

        range = -1;
        int loop1, loop2;
        //Target's x y z
        float tarx, tary, tarz;

        //Iterations per second
        int itmin;

        itmin = 128;


        //Pitch signal, Yaw signal
        float pthsig, yawsig;


        int hit, miss;
        //Last iteration position
        float otarx, otary, otarz;

        velcty = 200.0f;
        pitchr = 0.0f;
        yawr   = 0.0f;
        pthsig = 0.0f;
        yawsig = 0.0f;
        pitch  = ownerDirection.x * Mathf.Deg2Rad;
        yaw    = ownerDirection.y * Mathf.Deg2Rad;


        x = MathCalculations.ConvertUnityToMeters(ownerPosition.x, false);
        y = MathCalculations.ConvertUnityToMeters(ownerPosition.y, true);
        z = MathCalculations.ConvertUnityToMeters(ownerPosition.z, true);


        tarx = 0;
        tary = 0;
        tarz = 0;
        Gettar(ref tarx, ref tary, ref tarz, targetAircraft);

        hit  = 0;
        miss = 0;

        //Lets assume this loop1 = seconds
        for (loop1 = 1; loop1 <= 30; loop1++)
        {
            //For each second do 128 times
            for (loop2 = 1; loop2 <= itmin; loop2++)
            {
                otarx = tarx;
                otary = tary;
                otarz = tarz;
                Gettar(ref tarx, ref tary, ref tarz, targetAircraft);
                Calculations(ref velcty, ref pitchr, ref pthsig, ref yawr, ref yawsig
                             , ref pitch, ref yaw, ref x, ref y, ref z, ref tarx, ref tary, ref tarz, ref loop1,
                             ref loop2, ref itmin, ref hit, ref miss, ref otarx, ref otary, ref otarz, ref range);
                if (hit == 1)
                {
                    Debug.Log(string.Format("Target X = {0}, Target Y = {1}, Target Z = {2}", tarx, tary, tarz));
                    return(true);
                }
                if (miss == 1)
                {
                    return(false);
                }
                //Continue if still indeterminate
            }
        }

        return(hit == 1);
    }
示例#28
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //Object Position and rotation Updated
        if (flag && startReal)
        {
            if (counterAllData < alldata.Count)
            {
                if (timerTime >= timeDeltaConstant)
                {
                    timerTime = 0f;
                    //Display();
                    planeInfo.GetComponent <TextMesh>().text = "Call Sign: " + callsign + "\nTailID: " + tailID + "\nAltitude: " + altitude.ToString() + "\nHeading: " + heading.ToString() + "\nSpeed: " + speed.ToString();
                    //time.GetComponent<TextMesh>().text = "Local Time:\n" + localtime;
                    List <float> data = alldata[counterAllData];
                    dashboardData = alldata[counterAllData - 1];

                    //alldata.RemoveAt(0);
                    if (playdirection)
                    {
                        counterAllData++;
                    }
                    else
                    {
                        if (counterAllData != 0)
                        {
                            counterAllData--;
                        }
                    }


                    t2        = data[0];
                    localtime = MathCalculations.ConvertTime(t2);
                    if (t2 > t1)
                    {
                        timeToReachTarget = (float)(t2 - t1);
                    }
                    else
                    {
                        timeToReachTarget = (float)(t1 - t2);
                    }
                    timeDeltaConstant = timeToReachTarget;
                    t1       = t2;
                    altitude = data[3];
                    float[] xzy = MathCalculations.Convert(data[1], data[2], data[3]);
                    x = xzy[0];
                    z = xzy[1];
                    y = xzy[2];

                    //This is correct and verified
                    roll           = data[4];
                    pitch          = data[5];
                    heading        = data[6];
                    speed          = data[11];
                    targetRotation = Quaternion.Euler(pitch, heading, -roll);

                    /*assuming plane is facing left,
                     * roll is Rotation on longitudinal axis
                     * pitch is Rotation on lateral axis
                     * yaw is Rotation on vertical axis*/
                    if (data[14] != 0 || toggleMissileLaunch)
                    {
                        toggleMissileLaunch = false;
                        Debug.Log("Mission Event Happened");
                        int x = GetCounterAllData() + GetOffsetTime();
                        events.AddMissionEvent(localtime.ToString() + " " + callsign, x);
                        LaunchMissile();
                        //localtime.ToString() + " " + transform.name;
                    }


                    deltat        = 0;
                    startPosition = gameObject.transform.localPosition;
                    startRotation = gameObject.transform.localRotation;
                    //We are dealing with 200 milliseconds
                    //timeToReachTarget = 0.2f;
                    targetPosition = new Vector3(x, y, z);

                    //Vector3.RotateTowards(transform.forward, targetPosition, 0.2f * Time.deltaTime, 0.0f);
                    // transform.rotat(targetPosition);
                    //transform.rotation = Quaternion.LookRotation(targetPosition);
                }
                //gameObject.transform.position += transform.forward * Time.deltaTime * 2;
                float varDeltaTime = Time.fixedDeltaTime;
                float ratio        = varDeltaTime / timeToReachTarget;
                timerTime += varDeltaTime;
                gameObject.transform.localPosition = Vector3.Lerp(startPosition, targetPosition, ratio);
                //callSignObj.transform.localPosition = gameObject.transform.localPosition;
                transform.localRotation = Quaternion.Slerp(startRotation, targetRotation, ratio);
                // callSignObj.transform.localPosition = gameObject.transform.localPosition;
                timeToReachTarget -= varDeltaTime;
                anchor.SetPosition(0, gameObject.transform.GetChild(1).GetChild(1).position + (Vector3.down * 0.008f));
                anchor.SetPosition(1, gameObject.transform.GetChild(0).position);


                //Vector3 v = Camera.main.transform.position - transform.position;
                //v.x = v.z = 0.0f;
                //callSignObj.transform.LookAt(Camera.main.transform.position - v);
                //callSignObj.transform.Rotate(0, 180, 0);
            }
            else
            {
                dashboardData = alldata[counterAllData - 1];
            }
        }
    }
示例#29
0
    //Main thread
    //TODO : Parallel thread
    public void ExtractData(string debugPath = "")
    {
        counterAllData = 0;
        //type = textFile.name.Split('_')[0];
        //callsign = textFile.name.Split('_')[2];
        //Name = textFile.name.Split('_')[1];
        //string filePath = missionFolder + "\\RawData\\" + Filename.text;
        // UnityEngine.Debug.Log(filePath);
        string path;

        if (debugPath == "")
        {
            path = Application.dataPath + "\\StreamingAssets\\MissionData\\" + missionFolder + "\\RawData\\" + Filename.text + ".txt";
        }
        else
        {
            path = Application.dataPath + "\\StreamingAssets\\MissionData\\" + debugPath;
        }
        string FileData = File.ReadAllText(path);

        //TextAsset textFile = Resources.Load<TextAsset>("MissionData\\" + missionFolder + "\\RawData\\" + Filename.text) as TextAsset;

        //string path = Application.dataPath + "\\Resources\\MissionData\\" + missionFolder + "\\RawData\\" + Filename.text + ".txt";
        //string FileData = File.ReadAllText(path);
        //string text = textFile.text;

        string[] data = FileData.Split('\n').Skip(3).ToArray();
        alldata.Clear();

        foreach (var item in data)
        {
            if (!(item == ""))
            {
                string[]     datapoints = item.Split('\t');
                List <float> rdata      = new List <float>();
                int          maxFields  = 0;
                foreach (var datapoint in datapoints)
                {
                    float num1;
                    bool  res = float.TryParse(datapoint, out num1);
                    if (res)
                    {
                        rdata.Add(num1);
                        maxFields++;

                        if (maxFields >= 15)
                        {
                            break;
                        }
                    }
                }


                if (DateTimeOffset.Parse(MathCalculations.ConvertTime(rdata[0])) >= DateTimeOffset.Parse(MathCalculations.missionStart))
                {
                    if (taxiData.isOn)
                    {
                        if (typeAC.text == "AGSTA") //highest speed is 160 for AGSTA
                        {
                            if (rdata[11] >= 20)
                            {
                                alldata.Add(rdata);
                            }
                        }
                        else
                        {
                            if (rdata[11] >= 100)
                            {
                                alldata.Add(rdata);
                            }
                        }
                    }
                    else
                    {
                        alldata.Add(rdata);
                    }
                    //    //Data Extraction
                }
            }
        }

        t1        = alldata[0][0];
        localtime = MathCalculations.ConvertTime(t1, offset);
        starttime = localtime;

        endtime = MathCalculations.ConvertTime(alldata[alldata.Count - 1][0], offset);

        Save();
    }
示例#30
0
    public void ExtractData()
    {
        //type = textFile.name.Split('_')[0];
        //callsign = textFile.name.Split('_')[2];
        //Name = textFile.Split('_')[1];
        Name = (Path.GetFileName(textFile));

        string text = textFile;

        //textFile.text
        string[] data = text.Split('\n').Skip(3).ToArray();

        foreach (var item in data)
        {
            Debug.Log("All DATA ALTER ====" + item.ToString());
        }
        alldata.Clear();

        bool IsLoaded = false;

        if (loadFromFile)
        {
            IsLoaded = Load(Name);  //Load(textFile.name);
        }

        if (!IsLoaded)
        {
            foreach (var item in data)
            {
                if (!(item == ""))
                {
                    string[]     datapoints = item.Split('\t');
                    List <float> rdata      = new List <float>();
                    int          maxFields  = 0;
                    foreach (var datapoint in datapoints)
                    {
                        float num1;
                        bool  res = float.TryParse(datapoint, out num1);
                        if (res)
                        {
                            rdata.Add(num1);
                            maxFields++;

                            if (maxFields >= 15)
                            {
                                break;
                            }
                        }
                    }


                    if (DateTimeOffset.Parse(MathCalculations.ConvertTime(rdata[0])) >= DateTimeOffset.Parse(MathCalculations.missionStart))
                    {
                        //    //Data Extraction
                        if (type == "AGSTA") //highest speed is 160 for AGSTA
                        {
                            if (rdata[11] >= 20)
                            {
                                alldata.Add(rdata);
                            }
                        }
                        else
                        {
                            if (rdata[11] >= 100)
                            {
                                alldata.Add(rdata);
                            }
                        }
                    }
                }
            }
        }
    }