public static Corditanes GetRandom() { Corditanes c = new Corditanes(); c.SetRandom(); return(c); }
public static float Distance(Corditanes position1, Corditanes position2) { // перевести координаты в радианы float lat1 = position1.SDegree / 57.2958f; float lat2 = position2.SDegree / 57.2958f; float long1 = position1.DDegree / 57.2958f; float long2 = position2.DDegree / 57.2958f; // косинусы и синусы широт и разницы долгот float cl1 = Mathf.Cos(lat1); float cl2 = Mathf.Cos(lat2); float sl1 = Mathf.Sin(lat1); float sl2 = Mathf.Sin(lat2); float delta = long2 - long1; float cdelta = Mathf.Cos(delta); float sdelta = Mathf.Sin(delta); // вычисления длины большого круга float y = Mathf.Sqrt(Mathf.Pow(cl2 * sdelta, 2) + Mathf.Pow(cl1 * sl2 - sl1 * cl2 * cdelta, 2)); float x = sl1 * sl2 + cl1 * cl2 * cdelta; // float ad = Mathf.Atan2(y, x); float dist = ad * Setting.Instance.EARTH_RADIUS; return(dist / 1000); }
public void SetSity(Corditanes Place, string Name, float Pheromon, int SityID) { SityPlace = Place; SityObject.transform.position = SityPlace.ToPosition(new Vector3(0, 0, 0), 7.5f); SityName = Name; ID = SityID; PheromoneLevel = Pheromon; }
public void SetInsect(int InsectID, string IName, float Pheromone, float Regen = 0) { SityID = 0; SityGoalID = 0; ID = InsectID; InsectName = IName; PheromoneLeft = Pheromone; Regeneration = Regen; Place = new Corditanes(); Place.SetCoordinates(SityGenerator.Instance.ArrayOfSity[SityID].SityPlace.SDegree, SityGenerator.Instance.ArrayOfSity[SityID].SityPlace.DDegree); Memory = new List <int>(); InsectObject = this.gameObject; UpdatePosition(); UpdateMemory(); }
public void CreateSitys(int Amount) { ArrayOfSity = new List <SityBase>(); for (int i = 0; i < Amount; i++) { SityBase s = new SityBase(); s.SityObject = Instantiate(SityPrefab); if (i == 0) { s.SityObject.transform.localScale *= 2; } s.SetSity(Corditanes.GetRandom(), RandomName(), 0, i); //Debug.Log(s.SityName); ArrayOfSity.Add(s); } //Debug.Log(ArrayOfSity.Count); }
private void MoveTo() { Corditanes Delta = new Corditanes(); Delta.SetCoordinates(SityGenerator.Instance.ArrayOfSity[SityGoalID].SityPlace.SDegree - SityGenerator.Instance.ArrayOfSity[SityID].SityPlace.SDegree, SityGenerator.Instance.ArrayOfSity[SityGoalID].SityPlace.DDegree - SityGenerator.Instance.ArrayOfSity[SityID].SityPlace.DDegree); if (Delta.DDegree > 180) { Delta.DDegree = -360 + Delta.DDegree; } if (Delta.DDegree < -180) { Delta.DDegree = 360 + Delta.DDegree; } Corditanes Step = new Corditanes(); Step.SetCoordinates(Delta.SDegree / Setting.Instance.Speed, Delta.DDegree / Setting.Instance.Speed); Place.SetCoordinates(Place.SDegree + Step.SDegree, Place.DDegree + Step.DDegree); UpdatePosition(); }
// Use this for initialization void Start() { Cord1.SetCoordinates(SH1, DL1); Cord2.SetCoordinates(SH2, DL2); Debug.Log(Corditanes.Distance(Cord1, Cord2)); }
public void SolveDistance() { Corditanes cord1 = SityGenerator.Instance.GetSityFromID(IDSity1).SityPlace; Corditanes cord2 = SityGenerator.Instance.GetSityFromID(IDSity2).SityPlace; Distance = Corditanes.Distance(cord1, cord2); }