// Use this for initialization void Start() { Topography topography = GameObject.Find("topography").GetComponent <Topography>() as Topography; worldWidth = topography.chunkSize * topography.numChunks - topography.chunkSize * 3; worldHeight = topography.chunkSize * topography.numChunks - topography.chunkSize * 3; }
public void UpdateOutOfBounds() { if (Topography.IsNotInsideMapBoundaries(Position)) { Die(); } }
public void CutAndFillTest() { var models = new Dictionary <string, Elements.Model>(); var cells = 128; var elevations = new double[(int)Math.Pow(cells, 2)]; var y = 0; var z = 10.0; for (var x = 0; x < Math.Pow(cells, 2); x++) { if (x > cells - 1) { y++; } elevations[x] = z + 2 * Math.Sin(y / cells); } var topo = new Topography(Vector3.Origin, 500, elevations); var model = new Model(); model.AddElement(topo); models["location"] = model; var site = Polygon.Rectangle(Vector3.Origin, new Vector3(100, 100)); var t = new Transform(); t.Move(20, 20); var inputs = new CutAndFillInputs(site, new[] { (Polygon)Polygon.L(20, 10, 5).Transformed(t) }, 10, 45.0, null, null, null, null, null, null); var result = CutAndFill.Execute(models, inputs); result.Model.AddElement(new ModelCurve(site)); result.Model.ToGlTF("model.glb"); }
public override void Launch(IElementAttackable target, AWeapon weapon, Topography topography) { base.Launch(target, weapon, topography); AdjustHeadingForInaccuracy(); InitializeVelocity(); enabled = true; _collider.enabled = true; }
public ApplicationPlaceholderObject TopographyToNative(Topography speckleSurface) { var docObj = GetExistingElementByApplicationId(((Base)speckleSurface).applicationId); var pts = new List <XYZ>(); for (int i = 0; i < speckleSurface.baseGeometry.vertices.Count; i += 3) { pts.Add(new XYZ( ScaleToNative(speckleSurface.baseGeometry.vertices[i], speckleSurface.baseGeometry.units), ScaleToNative(speckleSurface.baseGeometry.vertices[i + 1], speckleSurface.baseGeometry.units), ScaleToNative(speckleSurface.baseGeometry.vertices[i + 2], speckleSurface.baseGeometry.units))); } if (docObj != null) { Doc.Delete(docObj.Id); } var revitSurface = TopographySurface.Create(Doc, pts); if (speckleSurface is RevitTopography rt) { SetInstanceParameters(revitSurface, rt); } return(new ApplicationPlaceholderObject { applicationId = ((Base)speckleSurface).applicationId, ApplicationGeneratedId = revitSurface.UniqueId, NativeObject = revitSurface }); }
public void CreateTopoFromMesh() { Name = nameof(CreateTopoFromMesh); var mesh = new Mesh(); // e---f---g---h // | / | / | / | // a---b---c---d var a = mesh.AddVertex((0, 0, 10)); var b = mesh.AddVertex((5, 0, 11)); var c = mesh.AddVertex((10, -1, 12)); var d = mesh.AddVertex((15, 1, 9)); var e = mesh.AddVertex((-1, 5, 8)); var f = mesh.AddVertex((6, 6, 9)); var g = mesh.AddVertex((11, 5, 10)); var h = mesh.AddVertex((16, 4, 11)); mesh.AddTriangle(a, b, f); mesh.AddTriangle(f, e, a); mesh.AddTriangle(b, c, g); mesh.AddTriangle(g, f, b); mesh.AddTriangle(c, d, h); mesh.AddTriangle(h, g, c); var topo = new Topography(mesh, null, new Transform(), Guid.NewGuid(), "Topo From Mesh"); var tunnel = new Line((7, -5, 5), (7, 10, 5)); topo.Tunnel(tunnel, 3); Model.AddElement(topo); }
public static TopographySurface ToNative(this Topography mySurface) { var(docObj, stateObj) = GetExistingElementByApplicationId(mySurface.ApplicationId, mySurface.Type); var pts = new List <XYZ>(); for (int i = 0; i < mySurface.Vertices.Count; i += 3) { pts.Add(new XYZ(mySurface.Vertices[i] * Scale, mySurface.Vertices[i + 1] * Scale, mySurface.Vertices[i + 2] * Scale)); } if (docObj != null) { Doc.Delete(docObj.Id); // TODO: Can't start a transaction here as we have started a global transaction for the creation of all objects. // TODO: Let each individual ToNative method handle its own transactions. It's a big change, so will leave for later. //var srf = (TopographySurface) docObj; //using( TopographyEditScope e = new TopographyEditScope( Doc, "Speckle Topo Edit" ) ) //{ // e.Start(srf.Id); // srf.DeletePoints( srf.GetPoints() ); // srf.AddPoints( pts ); // e.Commit( null ); //} //return srf; } return(TopographySurface.Create(Doc, pts)); }
public ApplicationPlaceholderObject TopographyToNative(Topography speckleSurface) { var docObj = GetExistingElementByApplicationId(((Base)speckleSurface).applicationId); var pts = new List <XYZ>(); for (int i = 0; i < speckleSurface.displayMesh.vertices.Count; i += 3) { var point = new Geometry.Point(speckleSurface.displayMesh.vertices[i], speckleSurface.displayMesh.vertices[i + 1], speckleSurface.displayMesh.vertices[i + 2], speckleSurface.displayMesh.units); pts.Add(PointToNative(point)); } if (docObj != null) { Doc.Delete(docObj.Id); } var revitSurface = TopographySurface.Create(Doc, pts); if (speckleSurface is RevitTopography rt) { SetInstanceParameters(revitSurface, rt); } //Report.Log($"Created Topography {revitSurface.Id}"); return(new ApplicationPlaceholderObject { applicationId = ((Base)speckleSurface).applicationId, ApplicationGeneratedId = revitSurface.UniqueId, NativeObject = revitSurface }); }
public static void RaonLauncherProjectile2ActiveTornado(Vector2 position) { Flipbook fb = new Flipbook(position, new Vector2(15.5f, 18.5f), 31, 29, "Graphics/Tank/RaonLauncherMineS2/CharacterSpritesheet", new AnimationInstance() { StartingFrame = 20, EndingFrame = 36, TimePerFrame = 1 / 10f }, DepthParameter.ProjectileSFX, 0); SpecialEffect se = new SpecialEffect(fb, 0); float positionMultiplier = 0; se.UpdateAction += (specialEffect, gameTime) => { if (Topography.IsNotInsideMapBoundaries(se.Flipbook.Position)) { SpecialEffectHandler.Remove(se); } se.Flipbook.Position -= new Vector2(0, positionMultiplier); se.Flipbook.Rotation += (float)gameTime.ElapsedGameTime.TotalSeconds * positionMultiplier * positionMultiplier * MathHelper.PiOver2; positionMultiplier += (float)gameTime.ElapsedGameTime.TotalSeconds; }; SpecialEffectHandler.Add(se); }
public void ByPoints_Mutation() { var p1 = Point.ByCoordinates(0, 0, 0); var p2 = Point.ByCoordinates(1, 3, 4); var p3 = Point.ByCoordinates(27, 5, 12); var p4 = Point.ByCoordinates(-10, 8, -3); var p5 = Point.ByCoordinates(.005, 0.01, -10); Assert.NotNull(p1); Assert.NotNull(p2); Assert.NotNull(p3); var topoSurf = Topography.ByPoints(new List <Point> { p1, p2, p3, p4, p5 }); Assert.NotNull(topoSurf); var p6 = Point.ByCoordinates(10, 42, -3.3); topoSurf = Topography.ByPoints(new List <Point> { p1, p2, p3, p4, p6 }); Assert.NotNull(topoSurf); topoSurf.Points[4].ShouldBeApproximately(p6); }
public virtual void UpdateSyncMobileToServer() { SyncMobile.MobileMetadata = MobileMetadata; SyncMobile.Position = Topography.GetRelativePosition(SyncPosition); SyncMobile.SelectedShotType = SelectedShotType; SyncMobile.CrosshairAngle = Crosshair.ShootingAngle; SyncMobile.Facing = Facing; }
private void CalculateJacobian(ref Weights ww, ref Index iw, ref Topography topo) { for (i = s + 1; i <= iw[o + 1 - ni] - 1; i++) { J[0, i] = node[topo[i]] * J[0, s]; delo[0, topo[i]] -= ww[i] * J[0, s]; } }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) { Response.Redirect("Default.aspx"); } else { user = (User)Session["User"]; user = CntAriCli.GetUser(user.UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "examinationassigned" select p).FirstOrDefault <Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["ExaminationAssignedId"] != null) { examinationAssignedId = Int32.Parse(Request.QueryString["ExaminationAssignedId"]); topography = (Topography)CntAriCli.GetExaminationAssigned(examinationAssignedId, ctx); LoadData(topography); } else { rdpExaminationDate.SelectedDate = DateTime.Now; } // if (Request.QueryString["PatientId"] != null) { patientId = int.Parse(Request.QueryString["PatientId"]); patient = CntAriCli.GetPatient(patientId, ctx); // fix rdc with patient rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString())); rdcPatient.SelectedValue = patient.PersonId.ToString(); rdcPatient.Enabled = false; } // if (Request.QueryString["VisitId"] != null) { visitId = int.Parse(Request.QueryString["VisitId"]); visit = CntAriCli.GetVisit(visitId, ctx); patientId = visit.Patient.PersonId; patient = CntAriCli.GetPatient(patientId, ctx); // fix rdc with patient rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString())); rdcPatient.SelectedValue = patient.PersonId.ToString(); rdcPatient.Enabled = false; // rdpExaminationDate.SelectedDate = visit.VisitDate; } }
//////////////////// /// CONSTRUCTORS /// //////////////////// public Cell(Topography topography, Vector2Int position, CellEvent cellChanged, Cell[,] cellMap, bool borderTile = false) { this.topography = GameObject.Instantiate(topography) as Topography; this.topography.parentCell = this; this.position = position; this.borderTile = borderTile; this.cellChanged = cellChanged; this.cellMap = cellMap; }
/// <summary> /// Initializes a new instance of the <see cref="FacilityData" /> class. /// </summary> /// <param name="facility">The facility.</param> /// <param name="owner">The owner.</param> /// <param name="passiveCMs">The passive countermeasures.</param> /// <param name="hullEquipment">The hull equipment.</param> /// <param name="activeCMs">The active countermeasures.</param> /// <param name="sensors">The sensors.</param> /// <param name="shieldGenerators">The shield generators.</param> /// <param name="hqPriority">The HQ priority.</param> /// <param name="topography">The topography.</param> public FacilityData(IFacility facility, Player owner, IEnumerable<PassiveCountermeasure> passiveCMs, FacilityHullEquipment hullEquipment, IEnumerable<ActiveCountermeasure> activeCMs, IEnumerable<Sensor> sensors, IEnumerable<ShieldGenerator> shieldGenerators, Priority hqPriority, Topography topography) : base(facility, owner, passiveCMs, hullEquipment, activeCMs, sensors, shieldGenerators, hqPriority) { Topography = topography; Science = hullEquipment.Science; Culture = hullEquipment.Culture; Income = hullEquipment.Income; }
private void UpdateElement(GameTime gameTime) { mobile.Rider.Update(); mobile.MobileFlipbook.Position += Parameter.AnimationInGameDeathAnimationSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; if (Topography.IsNotInsideMapBoundaries(mobile.MobileFlipbook.Position - new Vector2(0, 300)) && Topography.IsNotInsideMapBoundaries(mobile.MobileFlipbook.Position + new Vector2(0, 300))) { toBeDestroyedDeathAnimationList.Add(this); } }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) Response.Redirect("Default.aspx"); else { user = (User)Session["User"]; user = CntAriCli.GetUser(user.UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "examinationassigned" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["ExaminationAssignedId"] != null) { examinationAssignedId = Int32.Parse(Request.QueryString["ExaminationAssignedId"]); topography = (Topography)CntAriCli.GetExaminationAssigned(examinationAssignedId, ctx); LoadData(topography); } else { rdpExaminationDate.SelectedDate = DateTime.Now; } // if (Request.QueryString["PatientId"] != null) { patientId = int.Parse(Request.QueryString["PatientId"]); patient = CntAriCli.GetPatient(patientId, ctx); // fix rdc with patient rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString())); rdcPatient.SelectedValue = patient.PersonId.ToString(); rdcPatient.Enabled = false; } // if (Request.QueryString["VisitId"] != null) { visitId = int.Parse(Request.QueryString["VisitId"]); visit = CntAriCli.GetVisit(visitId, ctx); patientId = visit.Patient.PersonId; patient = CntAriCli.GetPatient(patientId, ctx); // fix rdc with patient rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString())); rdcPatient.SelectedValue = patient.PersonId.ToString(); rdcPatient.Enabled = false; // rdpExaminationDate.SelectedDate = visit.VisitDate; } }
public void Simple() { this.Name = "Topography_Simple"; var elevations = new double[] { 0.2, 1.0, 0.5, 0.25, 0.1, 0.2, 2.0, 0.05, 0.05 }; var topo = new Topography(Vector3.Origin, 3, elevations) { DepthBelowMinimumElevation = 3 }; this.Model.AddElement(topo); }
public void Simple() { this.Name = "TopographySimple"; var elevations = new double[] { 0.2, 1.0, 0.5, 0.25, 0.1, 0.2, 2.0, 0.05, 0.05 }; var colorizer = new Func <Triangle, Elements.Geometry.Color>((t) => { return(Colors.Green); }); var topo = new Topography(Vector3.Origin, 3, elevations); this.Model.AddElement(topo); }
/// <summary> /// Does this ray intersect the provided topography? /// </summary> /// <param name="topo">The topography.</param> /// <param name="result">The location of intersection.</param> /// <returns>True if an intersection result occurs. /// The type of intersection should be checked in the intersection result. /// False if no intersection occurs.</returns> public bool Intersects(Topography topo, out Vector3 result) { result = default(Vector3); foreach (var t in topo.Mesh.Triangles) { if (this.Intersects(t, out result)) { return(true); } } return(false); }
public void ByPoints_InvalidArgs() { var p1 = Point.ByCoordinates(0, 0, 0); var p2 = Point.ByCoordinates(1, 3, 4); Assert.NotNull(p1); Assert.NotNull(p2); Assert.Throws <System.Exception>(() => Topography.ByPoints(new List <Point> { p1, p2 })); }
protected void LoadData(Topography topo) { // Load patient data rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(topo.Patient.FullName, topo.Patient.PersonId.ToString())); rdcPatient.SelectedValue = topo.Patient.PersonId.ToString(); // Load Examination data rdcExamination.Items.Clear(); rdcExamination.Items.Add(new RadComboBoxItem(topo.Examination.Name, topo.Examination.ExaminationId.ToString())); rdcExamination.SelectedValue = topo.Examination.ExaminationId.ToString(); if (topo.LeftEyeK1 != null) { txtK1Left.Value = (double)topo.LeftEyeK1; } if (topo.RightEyeK1 != null) { txtK1Right.Value = (double)topo.RightEyeK1; } if (topo.LeftEyeK2 != null) { txtK2Left.Value = (double)topo.LeftEyeK2; } if (topo.RightEyeK2 != null) { txtK2Right.Value = (double)topo.RightEyeK2; } if (topo.LeftEyeAstig != null) { txtAstigLeft.Value = (double)topo.LeftEyeAstig; } if (topo.RightEyeAstig != null) { txtAstigRight.Value = (double)topo.RightEyeAstig; } if (topo.LeftEyeAxis != null) { txtAxisLeft.Value = (double)topo.LeftEyeAxis; } if (topo.RightEyeAxis != null) { txtAxisRight.Value = (double)topo.RightEyeAxis; } rdpExaminationDate.SelectedDate = topo.ExaminationDate; txtComments.Text = topo.Comments; }
private void CalculateForHiddenLayer(ref Index iw, ref Topography topo, ref Weights ww) { for (n = 0; n < nn - no; n++) { j = nio - n - 1; s = iw[j - ni]; J[0, s] = -derivates[j] * delo[0, j]; for (i = s + 1; i <= iw[j - ni + 1] - 1; i++) { J[0, i] = node[topo[i]] * J[0, s]; delo[0, topo[i]] -= ww[i] * J[0, s]; } } }
public void Simple() { this.Name = "TopographySimple"; var elevations = new double[] { 0.2, 1.0, 0.5, 0.25, 0.1, 0.2, 2.0, 0.05, 0.05, 0.2, 0.5, 0.6 }; var colorizer = new Func <Triangle, Color>((t) => { return(Colors.Green); }); var topo = new Topography(Vector3.Origin, 1.0, 1.0, elevations, 3, colorizer); this.Model.AddElement(topo); // var mass = new Mass(Polygon.Rectangle(0.75,1.0, new Vector3(2,1)), 3); // topo.Subtract(mass); // this.Model.AddElement(mass); }
public void Execute(Entity sectorEntity, int index, ref Sector sector) { DynamicBuffer <WorleySurfaceNoise> surfaceCellBuffer = SurfaceNoiseBufferFrom [sectorEntity]; DynamicBuffer <Topography> topographyBuffer = TopographyBufferFrom [sectorEntity]; topographyBuffer.ResizeUninitialized((int)math.pow(SectorSize, 2)); for (int i = 0; i < topographyBuffer.Length; i++) { int3 worldPosition = (int3)(sector.worldPosition + Util.Unflatten2D(i, SectorSize)); Topography heightComponent = GetStartingSurfaceCellHeight(surfaceCellBuffer[i], worldPosition); topographyBuffer[i] = heightComponent; } EntitiesForTagRemoval.Enqueue(sectorEntity); }
public override bool UpdateCollider(Vector2 position) { bool hasExploded = false; //Check collision with ground if (CanCollide && Topography.CheckCollision(position)) { hasExploded = true; Explode(); #if Debug debugCrosshair.Update(FlipbookList[0].Position); #endif } return(hasExploded); }
public IncomingWeatherPointer(WeatherMetadata weatherMetadata) { WeatherMetadata = weatherMetadata; fadeAnimation = 0; position = Topography.FromNormalizedPositionToRelativePosition(weatherMetadata.Position); flipbook = new Flipbook(Vector2.Zero, new Vector2(9, -11), 19, 27, "Interface/InGame/HUD/Blue/IncomingWeather/Pointer", new AnimationInstance { EndingFrame = 6, TimePerFrame = 1 / 15f }, 0.95f, 0); string text; switch (weatherMetadata.Weather) { case WeatherType.Force: text = Language.WeatherForce; break; case WeatherType.Tornado: text = Language.WeatherTornado; break; case WeatherType.Electricity: text = Language.WeatherElectricity; break; case WeatherType.Weakness: text = Language.WeatherWeakness; break; case WeatherType.Mirror: text = Language.WeatherMirror; break; default: text = Language.WeatherRandom; break; } spriteText = new SpriteText(FontTextType.Consolas10, text, Color.White, Alignment.Center, layerDepth: 1); flipbook.Position = new Vector2(position.X, -(GameScene.Camera.CameraOffset + Parameter.ScreenResolution / 2).Y); spriteText.Position = flipbook.Position + new Vector2(0, 0); flipbook.Color = spriteText.Color = spriteText.OutlineColor = Color.Transparent; }
public void RayIntersectsTopography() { this.Name = "RayIntersectTopo"; var elevations = new double[25]; int e = 0; for (var x = 0; x < 5; x++) { for (var y = 0; y < 5; y++) { elevations[e] = Math.Sin(((double)x / 5.0) * Math.PI) * 10; e++; } } var topo = new Topography(Vector3.Origin, 4, elevations); this.Model.AddElement(topo); var modelPoints = new ModelPoints(new List <Vector3>(), new Material("begin", Colors.Blue)); this.Model.AddElement(modelPoints); foreach (var t in topo.Mesh.Triangles) { var c = Center(t); var o = new Vector3(c.X, c.Y); modelPoints.Locations.Add(o); var ray = new Ray(o, Vector3.ZAxis); Vector3 xsect; if (ray.Intersects(t, out xsect)) { try { var l = new Line(o, xsect); var ml = new ModelCurve(l); this.Model.AddElement(ml); } catch { continue; } } } }
public void Example() { this.Name = "Elements_Topography"; // <example> // Read topo elevations from a file. var data = JsonConvert.DeserializeObject <Dictionary <string, double[]> >(File.ReadAllText("./elevations.json")); var elevations = data["points"]; var tileSize = WebMercatorProjection.GetTileSizeMeters(15); // Create a topography. var topo = new Topography(Vector3.Origin, tileSize, elevations); // </example> this.Model.AddElement(topo); }
public void Topography() { this.Name = "Topography"; // Read topo elevations var w = 512 / 8 - 1; var data = JsonConvert.DeserializeObject <Dictionary <string, double[]> >(File.ReadAllText("./elevations.json")); var elevations = data["points"]; // Compute the mapbox tile side lenth. var d = (40075016.685578 / Math.Pow(2, 15)) / w; Func <Triangle, Color> colorizer = (tri) => { var slope = tri.Normal.AngleTo(Vector3.ZAxis); if (slope >= 0.0 && slope < 15.0) { return(Colors.Green); } else if (slope >= 15.0 && slope < 30.0) { return(Colors.Yellow); } else if (slope >= 30.0 && slope < 45.0) { return(Colors.Orange); } else if (slope >= 45.0) { return(Colors.Red); } return(Colors.Red); }; var sw = new Stopwatch(); sw.Start(); var topo = new Topography(Vector3.Origin, d, d, elevations, w, colorizer); sw.Stop(); Console.WriteLine($"{sw.Elapsed.TotalMilliseconds}ms to create topography."); sw.Reset(); this.Model.AddElement(topo); }
/// <summary> /// Compute psudo hessian matrix and its gradient /// </summary> /// <param name="info">NetworkInfo - information about neural network</param> /// <param name="inp">Input - input data patterns used for learn</param> /// <param name="dout">Output - output data patterns used for learn</param> /// <param name="topo">Topography - neural network topography</param> /// <param name="ww">Weights - weights</param> /// <param name="act">Activation - activation function selection</param> /// <param name="gain">Gain - neuron gain</param> /// <param name="iw">Index - topography indexes</param> public void Compute(ref NetworkInfo info, ref Input inp, ref Output dout, ref Topography topo, Weights ww, ref Activation act, ref Gain gain, ref Index iw) { GradientMat = MatrixMB.Zeros(info.nw, 1); HessianMat = MatrixMB.Zeros(info.nw, info.nw); np = info.np; //number of patterns ni = info.ni; //number of inputs no = info.no; //number of outputs nw = info.nw; //number of weights nn = info.nn; //number of neurons nio = nn + ni - no; zeros = ni.Zeros(); delo = MatrixMB.Zeros(1, nio + 1); J = MatrixMB.Zeros(1, nw); for (p = 0; p < np; p++) { node.Clear(); node.AddRange(inp.Data[p]); CalculateFunctionValuesAndDerivates(ref ww, ref iw, ref topo, ref act, ref gain); for (k = 0; k < no; k++) { o = nio + k; error = dout.Data[p][k] - node[o]; J.ClearWithZeros(); s = iw.Pos(o - ni); J.Data[0][s] = -derivates[o]; delo.ClearWithZeros(); CalculateJacobian(ref ww, ref iw, ref topo); CalculateForHiddenLayer(ref iw, ref topo, ref ww); if (dout[p, 0] > 0.5) { J = J * ratio; } var JT = J.Transposed; GradientMat = GradientMat + JT * error; HessianMat = HessianMat + JT * J; } } }
public void HandleSyncMobile(SyncMobile syncMobile) { if (IsPlayable) { return; } SyncMobile.Update(syncMobile); //Position if (LevelScene.MatchMetadata != null && LevelScene.CurrentTurnOwner.Owner.ID == Owner.ID && Movement.IsAbleToMove) { ((RemoteMovement)Movement).EnqueuePosition(Topography.GetTransformedPosition(new Vector2(syncMobile.Position[0], syncMobile.Position[1])).ToVector2()); } //ShotType ChangeShot(SyncMobile.SelectedShotType); }
protected void UnloadData(Topography topo) { topo.Patient = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx); topo.ExaminationDate = (DateTime)rdpExaminationDate.SelectedDate; topo.Examination = CntAriCli.GetExamination(int.Parse(rdcExamination.SelectedValue), ctx); if (visit != null) { topo.BaseVisit = visit; } if (txtK1Left.Value != null) { topo.LeftEyeK1 = (decimal)txtK1Left.Value; } if (txtK1Right.Value != null) { topo.RightEyeK1 = (decimal)txtK1Right.Value; } if (txtK2Left.Value != null) { topo.LeftEyeK2 = (decimal)txtK2Left.Value; } if (txtK2Right.Value != null) { topo.RightEyeK2 = (decimal)txtK2Right.Value; } if (txtAstigLeft.Value != null) { topo.LeftEyeAstig = (decimal)txtAstigLeft.Value; } if (txtAstigRight.Value != null) { topo.RightEyeAstig = (decimal)txtAstigRight.Value; } if (txtAxisLeft.Value != null) { topo.LeftEyeAxis = (decimal)txtAxisLeft.Value; } if (txtAxisRight.Value != null) { topo.RightEyeAxis = (decimal)txtAxisRight.Value; } topo.Comments = txtComments.Text; }
/// <summary> /// Compute psudo hessian matrix and its gradient /// </summary> /// <param name="info">NetworkInfo - information about neural network</param> /// <param name="inp">Input - input data patterns used for learn</param> /// <param name="dout">Output - output data patterns used for learn</param> /// <param name="topo">Topography - neural network topography</param> /// <param name="ww">Weights - weights</param> /// <param name="act">Activation - activation function selection</param> /// <param name="gain">Gain - neuron gain</param> /// <param name="iw">Index - topography indexes</param> public void Compute(ref NetworkInfo info, ref Input inp, ref Output dout, ref Topography topo, Weights ww, ref Activation act, ref Gain gain, ref Index iw) { GradientMat = MatrixMB.Zeros(info.nw, 1); HessianMat = MatrixMB.Zeros(info.nw, info.nw); np = info.np;//number of patterns ni = info.ni;//number of inputs no = info.no;//number of outputs nw = info.nw;//number of weights nn = info.nn;//number of neurons nio = nn + ni - no; zeros = ni.Zeros(); delo = MatrixMB.Zeros(1, nio + 1); J = MatrixMB.Zeros(1, nw); for (p = 0; p < np; p++) { node.Clear(); node.AddRange(inp.Data[p]); CalculateFunctionValuesAndDerivates(ref ww, ref iw, ref topo, ref act, ref gain); for (k = 0; k < no; k++) { o = nio + k; error = dout.Data[p][k] - node[o]; J.ClearWithZeros(); s = iw.Pos(o - ni); J.Data[0][s] = -derivates[o]; delo.ClearWithZeros(); CalculateJacobian(ref ww, ref iw, ref topo); CalculateForHiddenLayer(ref iw, ref topo, ref ww); if (dout[p, 0] > 0.5) J = J * ratio; var JT = J.Transposed; GradientMat = GradientMat + JT * error; HessianMat = HessianMat + JT * J; } } }
/// <summary> /// Finds weight indexes /// </summary> /// <param name="topo">Topography - topography</param> /// <returns>WeightPointers - weight indexes</returns> public static Index Find(ref Topography topo) { var iw = new System.Collections.Generic.List<double>(); int nmax = 0; int i = 0; for (i = 0; i < topo.Length; i++) { if (topo.getValue(i) > nmax) { nmax = topo.getValue(i).ToInt(); iw.Add(i); } } iw.Add(i); Index ip = new Index(iw.Count); ip.Data[0] = iw.ToArray(); return ip; }
/// <summary> /// Total error calculation /// </summary> /// <param name="info">NetworkInfo</param> /// <param name="inp">ref Input - input data patterns</param> /// <param name="dout">ref Output - output data</param> /// <param name="topo">ref Topography - topo is network topology in the form of one vector</param> /// <param name="ww">ref Weights weights</param> /// <param name="act">ref Activation - type of activation function</param> /// <param name="gain">ref Gain - strengthening the activation function</param> /// <param name="iw">ref WeightsPointers - index pointers used for network topology stored in top in the form of one vector</param> /// <remarks>Network error will be overriden so please save it</remarks> public double CalculateError(ref NetworkInfo info, ref Input inp, ref Output dout, ref Topography topo, Weights ww, ref Activation act, ref Gain gain, ref Index iw) { try { Error = 0; for (p = 0; p < info.np; p++) { node.Clear(); node.AddRange(inp.Data[p]); for (n = 0; n < info.nn; n++) { net = ww[iw.Pos(n)]; int from = iw.Pos(n) + 1; int to = iw.Pos(n + 1) - 1; for (i = from; i <= to; i++) { net += node[(int)topo[i]] * ww[i]; } node.Add(ActivationFunction.computeFunction(ref n, ref net, ref act, ref gain)); } for (k = 0; k < info.no; k++) { Error += System.Math.Pow((dout.Data[p][k] - node[info.nio + k]), 2); } } return Error; } catch (System.Exception ex) { throw new NeuralNetworkError("Błąd uaktualnienia błędu sieci neuronowej. " + ex.Message, ex); } }
public override void Launch(IElementAttackable target, AWeapon weapon, Topography topography) { base.Launch(target, weapon, topography); _positionLastRangeCheck = Position; _rigidbody.velocity = ElementVelocityAtLaunch; _courseUpdatePeriod = new GameTimeDuration(1F / CourseUpdateFrequency); SteeringInaccuracy = CalcSteeringInaccuracy(); target.deathOneShot += TargetDeathEventHandler; _driftCorrector = new DriftCorrector(FullName, transform, _rigidbody); enabled = true; }
public override void Launch(IElementAttackable target, AWeapon weapon, Topography topography) { base.Launch(target, weapon, topography); InitializeVelocity(); enabled = true; }
public virtual void Launch(IElementAttackable target, AWeapon weapon, Topography topography) { if (_displayMgr == null) { // 8.9.16 moved from Awake() as PoolMgr spawns ordnance as soon as it wakes. In scene change from Lobby, this occurs // way before OnLevelIsLoaded() is called which is when GameMgr refreshes static References - aka TrackingWidgetFactory _displayMgr = InitializeDisplayMgr(); } _displayMgr.IsDisplayEnabled = true; PrepareForLaunch(target, weapon); D.AssertEqual(Layers.Projectiles, (Layers)gameObject.layer, ((Layers)gameObject.layer).GetValueName()); _launchPosition = transform.position; _rigidbody.drag = OpenSpaceDrag * topography.GetRelativeDensity(); _rigidbody.mass = Mass; AssessShowMuzzleEffects(); _hasWeaponFired = true; weapon.HandleFiringComplete(this); }
protected bool CreateChange() { if (!DataOk()) return false; if (topography == null) { topography = new Topography(); UnloadData(topography); ctx.Add(topography); } else { topography = (Topography)CntAriCli.GetExaminationAssigned(examinationAssignedId, ctx); UnloadData(topography); } ctx.SaveChanges(); return true; }
protected void LoadData(Topography topo) { // Load patient data rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(topo.Patient.FullName, topo.Patient.PersonId.ToString())); rdcPatient.SelectedValue = topo.Patient.PersonId.ToString(); // Load Examination data rdcExamination.Items.Clear(); rdcExamination.Items.Add(new RadComboBoxItem(topo.Examination.Name, topo.Examination.ExaminationId.ToString())); rdcExamination.SelectedValue = topo.Examination.ExaminationId.ToString(); if (topo.LeftEyeK1 != null) txtK1Left.Value = (double)topo.LeftEyeK1; if (topo.RightEyeK1 != null) txtK1Right.Value = (double)topo.RightEyeK1; if (topo.LeftEyeK2 != null) txtK2Left.Value = (double)topo.LeftEyeK2; if (topo.RightEyeK2 != null) txtK2Right.Value = (double)topo.RightEyeK2; if (topo.LeftEyeAstig != null) txtAstigLeft.Value = (double)topo.LeftEyeAstig; if (topo.RightEyeAstig != null) txtAstigRight.Value = (double)topo.RightEyeAstig; if (topo.LeftEyeAxis != null) txtAxisLeft.Value = (double)topo.LeftEyeAxis; if (topo.RightEyeAxis != null) txtAxisRight.Value = (double)topo.RightEyeAxis; rdpExaminationDate.SelectedDate = topo.ExaminationDate; txtComments.Text = topo.Comments; }
/// <summary> /// Initializes a new instance of the <see cref="ItemData" /> class. /// </summary> /// <param name="name">The name.</param> /// <param name="topography">The topography.</param> public ItemData(string name, Topography topography) : base(name) { base.Topography = topography; }
/// <summary> /// Initializes a new instance of the <see cref="FacilityData" /> class. /// </summary> /// <param name="stat">The stat.</param> /// <param name="topography">The topography.</param> public FacilityData(FacilityStat stat, Topography topography) : base(stat.Name, stat.Mass, stat.MaxHitPoints) { HullCategory = stat.Category; base.Topography = topography; }
public static void ImportExaminationsAssigned(OleDbConnection con, AriClinicContext ctx) { // (0) Borra tipos previos //ctx.Delete(ctx.WithoutGlassesTests); //ctx.Delete(ctx.GlassesTests); //ctx.Delete(ctx.ContactLensesTests); //ctx.Delete(ctx.OpticalObjectiveExaminations); //ctx.Delete(ctx.SubjectiveOpticalExaminations); //ctx.Delete(ctx.Cycloplegias); //ctx.Delete(ctx.PrescriptionGlasses); //ctx.Delete(ctx.Refractometries); //ctx.Delete(ctx.Biometries); //ctx.Delete(ctx.Paquimetries); //ctx.Delete(ctx.Topographies); //ctx.Delete(ctx.ExaminationAssigneds); //ctx.SaveChanges(); // (1) Dar de alta los diferentes diagnósticos string sql = "SELECT * FROM HistExplor"; cmd = new OleDbCommand(sql, con); da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "ConExploraciones"); int nreg = ds.Tables["ConExploraciones"].Rows.Count; int reg = 0; foreach (DataRow dr in ds.Tables["ConExploraciones"].Rows) { reg++; Boolean newEx = false; Console.WriteLine("Exploraciones asignadas {0:#####0} de {1:#####0} {2}", reg, nreg, "EXPASG"); int id = (int)dr["NumHis"]; Patient patient = (from p in ctx.Patients where p.OftId == id select p).FirstOrDefault<Patient>(); id = (int)dr["IdExEs"]; Examination examination = (from ex in ctx.Examinations where ex.OftId == id select ex).FirstOrDefault<Examination>(); DateTime examinationDate = (DateTime)dr["Fecha"]; ExaminationAssigned examas = (from e in ctx.ExaminationAssigneds where e.Patient.PersonId == patient.PersonId && e.Examination.ExaminationId == examination.ExaminationId && e.ExaminationDate == examinationDate select e).FirstOrDefault<ExaminationAssigned>(); if (examas == null) { examas = new ExaminationAssigned(); newEx = true; } examas.Patient = patient; examas.Examination = examination; examas.ExaminationDate = examinationDate; examas.Comments = (string)dr["Hallazgos"]; if ((int)dr["TipoProc"] == 1) { id = (int)dr["ExtProc"]; examas.BaseVisit = (from bs in ctx.BaseVisits where bs.OftRefVisita == id select bs).FirstOrDefault<BaseVisit>(); } switch (examas.Examination.ExaminationType.Code) { case "general": if (newEx) ctx.Add(examas); ctx.SaveChanges(); break; case "refractometry": Refractometry refra; if (newEx) refra = new Refractometry(); else refra = (Refractometry)examas; refra.Patient = examas.Patient; refra.Examination = examas.Examination; refra.ExaminationDate = examas.ExaminationDate; refra.BaseVisit = examas.BaseVisit; refra.Comments = examas.Comments; id = (int)dr["ExtExEs"]; ProcessRefractometry(id, refra, con, ctx); if (newEx) ctx.Add(refra); ctx.SaveChanges(); break; case "paquimetry": Paquimetry paq; if (newEx) paq = new Paquimetry(); else paq = (Paquimetry)examas; paq.Patient = examas.Patient; paq.Examination = examas.Examination; paq.ExaminationDate = examas.ExaminationDate; paq.BaseVisit = examas.BaseVisit; paq.Comments = examas.Comments; id = (int)dr["ExtExEs"]; ProcessPaquimetry(id, paq, con, ctx); if (newEx) ctx.Add(paq); ctx.SaveChanges(); break; case "biometry": Biometry bio; if (newEx) bio = new Biometry(); else bio = (Biometry)examas; bio.Patient = examas.Patient; bio.Examination = examas.Examination; bio.ExaminationDate = examas.ExaminationDate; bio.BaseVisit = examas.BaseVisit; bio.Comments = examas.Comments; if (newEx) ctx.Add(bio); ctx.SaveChanges(); break; case "topography": Topography top; if (newEx) top = new Topography(); else top = (Topography)examas; top.Patient = examas.Patient; top.Examination = examas.Examination; top.ExaminationDate = examas.ExaminationDate; top.BaseVisit = examas.BaseVisit; top.Comments = examas.Comments; if (newEx) ctx.Add(top); ctx.SaveChanges(); break; } } }
public void ChangeTopographyTo(Topography newTopography) { D.LogBold(ShowDebugLog, "{0}.ChangeTopographyTo({1}), Previous = {2}.", DebugName, newTopography.GetValueName(), Data.Topography.GetValueName()); Data.Topography = newTopography; }
public void ChangeTopographyTo(Topography newTopography) { D.Log(ShowDebugLog, "{0}.ChangeTopographyTo({1}).", DebugName, newTopography.GetValueName()); _rigidbody.drag = OpenSpaceDrag * newTopography.GetRelativeDensity(); }
public void OnTopographicBoundaryTransition(Topography newTopography) { //D.Log("{0}.OnTopographicBoundaryTransition({1}).", FullName, newTopography.GetName()); Data.Topography = newTopography; Data.AssessFtlAvailability(); }
/// <summary> /// Initializes a new instance of the <see cref="SystemItemData" /> class. /// </summary> /// <param name="systemName">Name of the system.</param> /// <param name="sectorIndex">Index of the sector.</param> /// <param name="topography">The topography.</param> public SystemItemData(string systemName, Index3D sectorIndex, Topography topography) : base(systemName) { SectorIndex = sectorIndex; base.Topography = topography; Subscribe(); }
protected void UnloadData(Topography topo) { topo.Patient = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx); topo.ExaminationDate = (DateTime)rdpExaminationDate.SelectedDate; topo.Examination = CntAriCli.GetExamination(int.Parse(rdcExamination.SelectedValue), ctx); if (visit != null) topo.BaseVisit = visit; if (txtK1Left.Value != null) topo.LeftEyeK1 = (decimal)txtK1Left.Value; if (txtK1Right.Value != null) topo.RightEyeK1 = (decimal)txtK1Right.Value; if (txtK2Left.Value != null) topo.LeftEyeK2 = (decimal)txtK2Left.Value; if (txtK2Right.Value != null) topo.RightEyeK2 = (decimal)txtK2Right.Value; if (txtAstigLeft.Value != null) topo.LeftEyeAstig = (decimal)txtAstigLeft.Value; if (txtAstigRight.Value != null) topo.RightEyeAstig = (decimal)txtAstigRight.Value; if (txtAxisLeft.Value != null) topo.LeftEyeAxis = (decimal)txtAxisLeft.Value; if (txtAxisRight.Value != null) topo.RightEyeAxis = (decimal)txtAxisRight.Value; topo.Comments = txtComments.Text; }
public void HandleTopographyChanged(Topography newTopography) { //D.Log("{0}.HandleTopographyChanged({1}).", FullName, newTopography.GetValueName()); _rigidbody.drag = OpenSpaceDrag * newTopography.GetRelativeDensity(); }
private void CalculateFunctionValuesAndDerivates(ref Weights ww, ref Index iw, ref Topography topo, ref Activation act, ref Gain gain) { derivates.Clear(); derivates.AddRange(node.Count.Zeros()); for (int n = 0; n < nn; n++)//for each neuron in network { net = ww[iw[n]];//calculate net sum for (i = iw[n] + 1; i <= iw[n + 1] - 1; i++) { net += (node[topo[i]] * ww[i]); } var res = ActivationFunction.computeFunctionDervative(ref n, ref net, ref act, ref gain);//and function value and its derivative node.Add(res.FunctionResult);//save function value for output signal from neuron derivates.Add(res.FunctionDerivative);//save function derivative value for output signal from neuron } }
public virtual void Launch(IElementAttackable target, AWeapon weapon, Topography topography) { PrepareForLaunch(target, weapon); D.Assert((Layers)gameObject.layer == Layers.Projectiles, "{0} is not on Layer {1}.".Inject(Name, Layers.Projectiles.GetValueName())); _launchPosition = transform.position; _rigidbody.drag = OpenSpaceDrag * topography.GetRelativeDensity(); _rigidbody.mass = Mass; AssessShowMuzzleEffects(); _hasWeaponFired = true; weapon.HandleFiringComplete(this); _displayMgr = InitializeDisplayMgr(); }