IEnumerator Move() { if (orbitActive) { for (i = 0; i < 606; i++) { nextPosition = Calculations.CalculateOrbitalPosition (teslaPositions[i].semimajorAxis, teslaPositions[i].eccentricity, teslaPositions[i].inclination, teslaPositions[i].longitudeOfAscendingNode, teslaPositions[i].periapsisArgument, teslaPositions[i].trueAnomaly); nextPosition.x /= div; nextPosition.y /= div; nextPosition.z /= div; PositionText.text = ("Position: " + nextPosition); DateText.text = ("Date: " + teslaPositions[i].date); orbitingObject.localPosition = new Vector3((float)nextPosition.x, (float)nextPosition.y, (float)nextPosition.z); yield return(new WaitForSeconds(0.01f)); } } StartCoroutine(Move()); }
public Vector3 GetLocalPosition(Vector3Double globalPosition) { return(new Vector3( (float)(globalPosition.x - Handle.X), (float)(globalPosition.y), (float)(globalPosition.z - Handle.Y))); }
void Start() { speed[0].GetComponent <Image>().color = Color.blue; DateTime dt = DateTime.FromOADate(double.Parse(list.dataArray[x].Dateutc, System.Globalization.CultureInfo.InvariantCulture)); dt = TimeZoneInfo.ConvertTime(dt, TimeZoneInfo.Local).ToLocalTime(); string time = dt.ToString(); dateNow.GetComponent <TextMeshProUGUI>().text = time; PosD = RG.OrbitalElements.Calculations.CalculateOrbitalPosition(double.Parse(list.dataArray[x].Semimajoraxisau, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Eccentricity, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Inclinationdegrees, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Longitudeofascnodedegrees, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Argumentofperiapsisdegrees, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Trueanomalydegrees, System.Globalization.CultureInfo.InvariantCulture)); Tesla.transform.position = new Vector3((float)PosD.x / AdD, (float)PosD.y / AdD, (float)PosD.z / AdD); values[0].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Semimajoraxisau; values[1].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Eccentricity; values[2].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Inclinationdegrees; values[3].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Longitudeofascnodedegrees; values[4].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Argumentofperiapsisdegrees; values[5].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Meananomalydegrees; values[6].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Trueanomalydegrees; x++; speed[0].GetComponent <Button>().onClick.AddListener(() => SetSpeed(speed[0], 1)); speed[1].GetComponent <Button>().onClick.AddListener(() => SetSpeed(speed[1], 2)); speed[2].GetComponent <Button>().onClick.AddListener(() => SetSpeed(speed[2], 4)); }
public static Vector3Double SmoothDamp(Vector3Double current, Vector3Double target, ref Vector3Double currentVelocity, double smoothTime, double maxSpeed) { double deltaTime = (double)Time.deltaTime; return(Vector3Double.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime)); }
public QuadTreeNode(GraphicsDevice graphicsDevice, HeightProvider heightProvider, NodeType nodeType, QuadTreeNode parentNode, float edgeLengthFlat, Vector3Double originPositionFlat, Vector3 upDirectionFlat, Vector3 rightDirectionFlat, float radiusSphere) { _graphicsDevice = graphicsDevice; _heightProvider = heightProvider; _nodeType = nodeType; _parentNode = parentNode; _edgeLengthFlat = edgeLengthFlat; _halfEdgeLengthFlat = _edgeLengthFlat / 2; _quarterEdgeLengthFlat = _edgeLengthFlat / 4; _originPositionFlat = originPositionFlat; _upDirectionFlat = upDirectionFlat; _rightDirectionFlat = rightDirectionFlat; _radiusSphere = radiusSphere; Vector3 originPositionSphereNormal = Vector3Double.Normalize(_originPositionFlat); Vector3Double originPositionSpherePosition = new Vector3Double(_radiusSphere * originPositionSphereNormal); OriginPositionSphere = originPositionSpherePosition + _heightProvider.GetHeight(originPositionSpherePosition) * originPositionSphereNormal; IndexBuffer = _indexBuffers[IndexBufferSelection.Base]; }
public static void AddVector3(this JsonData target, string name, Vector3Double value) { target[name] = new JsonData(); target[name]["x"] = value.x; target[name]["y"] = value.y; target[name]["z"] = value.z; }
/// <summary> /// Algorithme IGN : http://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/alg0063.pdf /// A partir d’un jeu de 7 paramètres (3 translations, 1 facteur d’échelle et /// 3 rotations) de passage du système(1) vers le système(2), et des coordonnées /// cartésiennes tridimensionnelles dans le système(2), calcul des coordonnées /// cartésiennes tridimensionnelles dans le système(1) /// </summary> /// <param name="t">Translation (de 1 vers 2)</param> /// <param name="d">facteur d'echelle (de 1 vers 2)</param> /// <param name="r">angle de rotation (de 1 vers 2)</param> /// <param name="v">vecteur de coordonnées cartésiennes tridimension-nelles dans le système(2)</param> /// <returns>vecteur de coordonnées cartésiennes tridimension-nelles dans le système(1)</returns> internal Vector3Double ALG0063(Vector3Double t, double d, Vector3Double r, Vector3Double v) { var w = new Vector3Double(); w.X = v.X - t.X; w.Y = v.Y - t.Y; w.Z = v.Z - t.Z; var e = 1 + d; var det = e * (e * e + r.X * r.X + r.Y * r.Y + r.Z * r.Z); var e2Rx2 = e * e + r.X * r.X; var e2Ry2 = e * e + r.Y * r.Y; var e2Rz2 = e * e + r.Z * r.Z; var RxRy = r.X * r.Y; var RyRz = r.Y * r.Z; var RxRz = r.Z * r.X; var result = new Vector3Double(); result.X = e2Rx2 * w.X + (RxRy + e * r.Z) * w.Y + (RxRz - e * r.Y) * w.Z; result.Y = (RxRy - e * r.Z) * w.X + e2Ry2 * w.Y + (RyRz + e * r.X) * w.Z; result.Z = (RxRz + e * r.Y) * w.X + (RyRz - e * r.X) * w.Y + e2Rz2 * w.Z; result.X /= det; result.Y /= det; result.Z /= det; return(result); }
public static Vector3Double SmoothDamp(Vector3Double current, Vector3Double target, ref Vector3Double currentVelocity, double smoothTime, double maxSpeed, double deltaTime) { smoothTime = CGMath.Max(0.0001d, smoothTime); double num1 = 2d / smoothTime; double num2 = num1 * deltaTime; double num3 = (1.0d / (1.0d + num2 + 0.479999989271164d * num2 * num2 + 0.234999999403954d * num2 * num2 * num2)); Vector3Double vector = current - target; Vector3Double vector3_1 = target; double maxLength = maxSpeed * smoothTime; Vector3Double vector3_2 = Vector3Double.ClampMagnitude(vector, maxLength); target = current - vector3_2; Vector3Double vector3_3 = (currentVelocity + num1 * vector3_2) * deltaTime; currentVelocity = (currentVelocity - num1 * vector3_3) * num3; Vector3Double vector3_4 = target + (vector3_2 + vector3_3) * num3; if (!(Vector3Double.Dot(vector3_1 - current, vector3_4 - vector3_1) > 0.0)) { return(vector3_4); } vector3_4 = vector3_1; currentVelocity = (vector3_4 - vector3_1) / deltaTime; return(vector3_4); }
private void CreatePositionsList() { for (int i = 0; i < AllRawData.Count; i++) { Vector3Double tempVector = Calc.CalculateOrbitalPosition(AllRawData[i].semimajorAxis, AllRawData[i].eccentricity, AllRawData[i].inclination, AllRawData[i].longitudeOfAscendingNode, AllRawData[i].periapsisArgument, AllRawData[i].trueAnomaly); AllPositions.Add(tempVector); } }
public static Vector3Double RotateTowards(Vector3Double current, Vector3Double target, double maxRadiansDelta, double maxMagnitudeDelta) { Vector3 v3 = Vector3.RotateTowards((Vector3)current, (Vector3)target, (float)maxRadiansDelta, (float)maxMagnitudeDelta); return(new Vector3Double(v3)); }
Vector3 VectorForUnity(DataRow row) { Vector3Double vec = OrbitHelper.OrbitalStateVectors(GetDouble(row[2]), GetDouble(row[3]), GetDouble(row[4]), GetDouble(row[5]), GetDouble(row[6]), GetDouble(row[8]));//Calculations.CalculateOrbitalPosition(GetDouble(row[2]), GetDouble(row[3]), GetDouble(row[4]), GetDouble(row[5]), GetDouble(row[6]), GetDouble(row[8])); Vector3 v = (vec / div).ToFLoat(); return(v); }
public static GeodeticCoord DatabaseToGeodetic(Vector3Double database) { return(new GeodeticCoord( (database.Z * 180.0) / (flat_earth_radius * PI) + _refLatLon.Lat, (database.X * 180.0) / (flat_earth_radius * PI * Cos(DegreesToRadians(_refLatLon.Lat))) + _refLatLon.Lon, database.Y )); }
public static Vector3Double ClampMagnitude(Vector3Double vector, double maxLength) { if (vector.sqrMagnitude > maxLength * maxLength) { return(vector.normalized * maxLength); } return(vector); }
public static Vector3Double Project(Vector3Double vector, Vector3Double onNormal) { double num = Vector3Double.Dot(onNormal, onNormal); if (num < 1.40129846432482E-45d) { return(Vector3Double.zero); } return(onNormal * Vector3Double.Dot(vector, onNormal) / num); }
public static Vector3Double Normalize(Vector3Double value) { double num = Vector3Double.Magnitude(value); if (num > 9.99999974737875E-06) { return(value / num); } return(Vector3Double.zero); }
public static Vector3Double MoveTowards(Vector3Double current, Vector3Double target, double maxDistanceDelta) { Vector3Double vector3 = target - current; double magnitude = vector3.magnitude; if (magnitude <= maxDistanceDelta || magnitude == 0.0d) { return(target); } return(current + vector3 / magnitude * maxDistanceDelta); }
public static void OrthoNormalize(ref Vector3Double normal, ref Vector3Double tangent) { Vector3 v3normal = new Vector3(); Vector3 v3tangent = new Vector3(); v3normal = (Vector3)normal; v3tangent = (Vector3)tangent; Vector3.OrthoNormalize(ref v3normal, ref v3tangent); normal = new Vector3Double(v3normal); tangent = new Vector3Double(v3tangent); }
/// <summary> /// Algorithme IGN : http://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/notice/NTG_80.pdf /// A partir d’un jeu de 7 paramètres (3 translations, 1 facteur d’échelle et /// 3 rotations) de passage du système(1) vers le système(2), et des coordonnées /// cartésiennes tridimensionnelles dans le système(1), calcul des coordonnées /// cartésiennes tridimensionnelles dans le système(2) /// </summary> /// <param name="t">Translation (de 1 vers 2)</param> /// <param name="d">facteur d'echelle (de 1 vers 2)</param> /// <param name="r">angle de rotation (de 1 vers 2)</param> /// <param name="u">vecteur de coordonnées cartésiennes tridimension-nellesdans le système(1)</param> /// <returns>vecteur de coordonnées cartésiennes tridimension-nelles dans le système(2)</returns> internal Vector3Double ALG0013(Vector3Double t, double d, Vector3Double r, Vector3Double u) { var dp1 = 1 + d; return(new Vector3Double { X = t.X + u.X * dp1 + u.Z * r.Y - u.Y * r.Z, Y = t.Y + u.Y * dp1 + u.X * r.Z - u.Z * r.X, Z = t.Z + u.Z * dp1 + u.Y * r.X - u.X * r.Y }); }
public void Normalize() { double num = Vector3Double.Magnitude(this); if (num > 9.99999974737875E-06) { this = this / num; } else { this = Vector3Double.zero; } }
/// <summary> /// /// </summary> /// <returns>true if we did NOT update the texture</returns> public bool UpdateTexture() { if (SurfaceTextureUpdate == false) { return(true); } float metersPerGrid = Surface.MetersPerGrid; float gridsPerPatchEdge = (float)Surface.GridsPerPatchEdge; if (GetNeighbourPatch(DirectionIndex.East) == null && !GetNeighbourPatch(DirectionIndex.East).HasReceivedData || GetNeighbourPatch(DirectionIndex.West) == null && !GetNeighbourPatch(DirectionIndex.West).HasReceivedData || GetNeighbourPatch(DirectionIndex.South) == null && !GetNeighbourPatch(DirectionIndex.South).HasReceivedData || GetNeighbourPatch(DirectionIndex.North) == null && !GetNeighbourPatch(DirectionIndex.North).HasReceivedData) { return(false); } Region region = Surface.Region; Vector3Double originRegion = OriginGlobal.Subtract(Surface.OriginGlobal); // Have to figure out a better way to deal with these edge conditions... //if (HeightsGenerated == true) //{ // return false; //} float patchSize = metersPerGrid * (gridsPerPatchEdge + 1); //TODO: VLComposition comp = region.Composition; // TODO: if (comp.GenerateHeights ((float) originRegion.x, (float) originRegion.y, patchSize, patchSize) == false) // TODO: Should y be z? //{ // return false; //} HeightsGenerated = true; // TODO: if (comp.GenerateComposition()) //{ // if (VObjp) // { // VObjp->dirtyGeom(); // Pipeline.markGLRebuild(mVObjp); // return true; // } //} return(false); }
public static double Turbulence(Vector3Double v, double freq) { double t; Vector3Double vec; for (t = 0.0f; freq >= 1.0f; freq /= 2) { vec.x = freq * v[0]; vec.y = freq * v[1]; vec.z = freq * v[2]; t += Math.Abs(Generate(vec.x, vec.y, vec.z)) / freq; } return(t); }
public override bool Equals(object other) { if (!(other is Vector3Double)) { return(false); } Vector3Double vector3Double = (Vector3Double)other; if (this.x.Equals(vector3Double.x) && this.y.Equals(vector3Double.y)) { return(this.z.Equals(vector3Double.z)); } return(false); }
public Vector3 GetNormalFromFiniteOffset(Vector3Double location) { Vector3 normalisedLocation = Vector3Double.Normalize(location); Vector3 arbitraryUnitVector = Math.Abs(normalisedLocation.Y) > Math.Abs(normalisedLocation.X) ? Vector3.UnitX : Vector3.UnitY; Vector3 tangentVector1 = Vector3.Normalize(Vector3.Cross(arbitraryUnitVector, normalisedLocation)); Vector3 tangentVector2 = Vector3.Normalize(Vector3.Cross(tangentVector1, normalisedLocation)); float hL = GetHeight(location - tangentVector1 * NormalSampleOffset); float hR = GetHeight(location + tangentVector1 * NormalSampleOffset); float hD = GetHeight(location - tangentVector2 * NormalSampleOffset); float hU = GetHeight(location + tangentVector2 * NormalSampleOffset); return(Vector3.Normalize(2 * normalisedLocation + (hL - hR) * tangentVector1 + (hD - hU) * tangentVector2)); }
public void Demonstrate() { Console.WriteLine("[SENDER - INFO] Started sending example"); //Marnehuizen double lat = 53.3889139; double lon = 6.263677777777778; EntityStatePdu espdu = new EntityStatePdu(); espdu.ExerciseID = 1; EntityID eid = espdu.EntityID; eid.Site = 0; eid.Application = 1; eid.Entity = 2; EntityType entityType = espdu.EntityType; entityType.Country = (ushort)Country.Netherlands; // NL entityType.EntityKind = (byte)EntityKind.LifeForm; // Life form (vs platform, munition, sensor, etc.) entityType.Domain = (byte)Platform.Land; // Land (vs air, surface, subsurface, space) entityType.Category = 0; //empty entityType.Subcategory = 1; // Dismounted entityType.Specific = 5; //carrying an assault rifle entityType.Extra = 1; //Moving alone while (true) { lat += (1d / 11132000); lon += (1d / 40075) * Math.Cos(lat) / 360d; double[] disCoordinates = CoordinateConversions.getXYZfromLatLonDegrees(lat, lon, 0.0); Console.WriteLine("[SENDER - INFO] Entity is now at (lat:{0}, long:{1}", lat, lon); Vector3Double location = espdu.EntityLocation; location.X = disCoordinates[0]; location.Y = disCoordinates[1]; location.Z = disCoordinates[2]; espdu.Timestamp = DisTime.DisRelativeTimestamp; //send the constructed PDU to the specified multicast group _connector.sendPDU(espdu, MulticastGroup.Parse("224.5.5.5")); Console.WriteLine("[SENDER - INFO] PDU broadcasted"); Thread.Sleep(15000); } }
void Update() { Earth.transform.position = RotatePointAroundPivot(Earth.transform.position + new Vector3(5, 0, 10f), Sun.transform.position, Quaternion.Euler(0, 50f * 0.00033f * rotationSpeed, 0)); Mercury.transform.position = RotatePointAroundPivot(Mercury.transform.position + new Vector3(0, 0, 5f), Sun.transform.position, Quaternion.Euler(0, 50f * 0.0018f * rotationSpeed, 0)); Venus.transform.position = RotatePointAroundPivot(Venus.transform.position + new Vector3(5, 0, 5f), Sun.transform.position, Quaternion.Euler(0, 50f * 0.00125f * rotationSpeed, 0)); if (IsAble) { cur = Tesla.transform.position; DateTime dt = DateTime.FromOADate(double.Parse(list.dataArray[x].Dateutc, System.Globalization.CultureInfo.InvariantCulture)); dt = TimeZoneInfo.ConvertTime(dt, TimeZoneInfo.Local).ToLocalTime(); string time = dt.ToString(); dateNow.GetComponent <TextMeshProUGUI>().text = time; PosD = RG.OrbitalElements.Calculations.CalculateOrbitalPosition(double.Parse(list.dataArray[x].Semimajoraxisau, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Eccentricity, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Inclinationdegrees, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Longitudeofascnodedegrees, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Argumentofperiapsisdegrees, System.Globalization.CultureInfo.InvariantCulture), double.Parse(list.dataArray[x].Trueanomalydegrees, System.Globalization.CultureInfo.InvariantCulture)); values[0].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Semimajoraxisau; values[1].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Eccentricity; values[2].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Inclinationdegrees; values[3].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Longitudeofascnodedegrees; values[4].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Argumentofperiapsisdegrees; values[5].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Meananomalydegrees; values[6].GetComponent <TextMeshProUGUI>().text = list.dataArray[x].Trueanomalydegrees; PosF = new Vector3((float)PosD.x / AdD, (float)PosD.y / AdD, (float)PosD.z / AdD); x++; IsAble = false; RotationPercentage = 1f; } else if (!IsAble) { RotationPercentage -= 0.01f * rotationSpeed; Tesla.transform.position = Vector3.Slerp(PosF, cur, RotationPercentage); if (RotationPercentage <= 0.45f) { IsAble = true; } } if (x == 606) { Debug.Log("We reached final destination!"); x = 49; } }
} // Patch whose coordinate system this surface is using. public Surface(SurfaceType surfaceType, Region region) { SurfaceType = surfaceType; Region = region; GridsPerEdge = 0; OOGridsPerEdge = 0f; PatchesPerEdge = 0; NumberOfPatches = 0; DetailTextureScale = 0f; OriginGlobal = new Vector3Double(0.0, 0.0, 0.0); //STexturep(NULL), //WaterTexturep(NULL), GridsPerPatchEdge = 0; MetersPerGrid = 1.0f; MetersPerEdge = 1.0f; // Surface data SurfaceZ = null; Norm = null; // Patch data PatchList = null; // One of each for each camera VisiblePatchCount = 0; HasZData = false; // "uninitialized" min/max z MinZ = 10000f; MaxZ = -10000f; //WaterObj = NULL; // In here temporarily. SurfacePatchUpdateCount = 0; for (int i = 0; i < 8; i++) { Neighbours[i] = null; } }
public void Update(Vector3Double cameraPosition) { // Absorb queues and update root nodes if (_rootNodeUpdateThread == null || !_rootNodeUpdateThread.IsAlive) { RenderQueue.Clear(); foreach (List <QuadTreeNode> newRenderQueue in _newRenderQueues) { RenderQueue.AddRange(newRenderQueue); } RenderQueue.ForEach(node => node.FixCracks()); foreach (List <QuadTreeNode> newDisposalQueue in _newDisposalQueues) { newDisposalQueue.ForEach(node => node.Dispose()); } _rootNodeUpdateThread = new Thread(UpdateRootNodes); _rootNodeUpdateThread.Start(cameraPosition); } }
/// <summary> /// Assumes that arguments are powers of 2, and that /// gridsPerEdge / gridsPerPatchEdge = power of 2 /// </summary> /// <param name="gridsPerRegionEdge"></param> /// <param name="gridsPerPatchEdge"></param> /// <param name="originGlobal"></param> /// <param name="width">in metres</param> public void Create(UInt32 gridsPerEdge, UInt32 gridsPerPatchEdge, Vector3Double originGlobal, float width) { // Initialize various constants for the surface GridsPerEdge = gridsPerEdge + 1; // Add 1 for the east and north buffer OOGridsPerEdge = 1f / GridsPerEdge; GridsPerPatchEdge = gridsPerPatchEdge; PatchesPerEdge = ((GridsPerEdge - 1) / GridsPerPatchEdge); NumberOfPatches = PatchesPerEdge * PatchesPerEdge; MetersPerGrid = width / (GridsPerEdge - 1); MetersPerEdge = MetersPerGrid * (GridsPerEdge - 1); OriginGlobal = originGlobal; //TODO: PVArray.create(GridsPerEdge, GridsPerPatchEdge, LLWorld::getInstance()->getRegionScale()); UInt32 nGrids = GridsPerEdge * GridsPerEdge; // Initialize data arrays for surface SurfaceZ = new float[nGrids]; Norm = new Vector3[nGrids]; // Reset the surface to be a flat square grid for (int i = 0; i < nGrids; i++) { // Surface is flat and zero // Normals all point up SurfaceZ[i] = 0.0f; Norm[i] = new Vector3(0f, 0f, 1f); } VisiblePatchCount = 0; InitTextures(); // Has to be done after texture initialization CreatePatchData(); }
public static Vector3Double Max(Vector3Double lhs, Vector3Double rhs) { return(new Vector3Double(CGMath.Max(lhs.x, rhs.x), CGMath.Max(lhs.y, rhs.y), CGMath.Max(lhs.z, rhs.z))); }
public static double SqrMagnitude(Vector3Double a) { return(a.x * a.x + a.y * a.y + a.z * a.z); }