protected void _applyGlobalForce(IForce force) { foreach (RigidBody body in _bodies) { body.applyForce(force); } }
void Awake() { _forcePhysics = new GravityForce(); _registeredBodies = new List <IntSatData>(); _parent = transform.GetComponentInParent <MovementBehaviour>(); _satelliteManagerBehavior = GetComponentInParent <SatelliteManager>(); }
private void btnOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtConcern.Text) || !_concernMap.ContainsKey(txtConcern.Text)) { txtConcern.Select(0, txtConcern.TextLength); MessageBox.Show(string.Format(Messages.SelectForceDialogConcernDoesNotExist, txtConcern.Text)); return; } if (string.IsNullOrEmpty(txtForce.Text) || !_forcesMap.ContainsKey(txtForce.Text)) { txtConcern.Select(0, txtForce.TextLength); MessageBox.Show(string.Format(Messages.SelectForceDialogForceDoesNotExist, txtForce.Text)); return; } Force = new Force(_forcesMap[txtForce.Text]); Concern = new Concern(_concernMap[txtConcern.Text]); var forceExists = (from x in _forces where x.Force.ForceGUID.Equals(Force.ForceGUID) && x.Concern.ConcernGUID.Equals(Concern.ConcernGUID) select x).Any(); if (forceExists) { MessageBox.Show(string.Format(Messages.ForcesViewForceExists, Force.Name, Concern.Name)); return; } DialogResult = DialogResult.OK; Close(); }
/// <summary> /// Add a new IForce function to the simulator. /// </summary> /// <param name="f">the IForce function to add</param> public void AddForce(IForce f) { if (f.IsItemForce) { if (iforces.Length == iflen) { // resize necessary IForce[] newf = new IForce[iflen + 10]; Array.Copy(iforces, 0, newf, 0, iforces.Length); iforces = newf; } iforces[iflen++] = f; } if (f.IsSpringForce) { if (sforces.Length == sflen) { // resize necessary IForce[] newf = new IForce[sflen + 10]; Array.Copy(sforces, 0, newf, 0, sforces.Length); sforces = newf; } sforces[sflen++] = f; } }
public DEM(ISpacePartitioning<int> spacePartitioner, IForce externalForce, IForce boundaryForce) { this.spacePartitioner = spacePartitioner; this.externalForce = externalForce; this.boundaryForce = boundaryForce; }
public DecisionEvaluation(IDecision decision, IConcern concern, IForce force) { Decision = decision; Concern = concern; Force = force; var connector = GetConnector(Force.Element); if (connector == null) { Rating = string.Empty; Rationale = string.Empty; BackgroundColor = Color.White.ToArgb(); Changed = true; //this is new so it has changed PropertyChanged += OnPropertyChanged; return; } Rating = connector.GetTaggedValueByName(RatingTag); Rationale = connector.GetTaggedValueByName(RationaleTag); int temp; int.TryParse(connector.GetTaggedValueByName(ColorTag), out temp); BackgroundColor = temp; PropertyChanged += OnPropertyChanged; }
public ArtificialIntelligence(World world, Boid self) : base(world, self) { enemyForce = new BoidAttractionForce(HunterAttractionConstant, HunterAttractionExponent, EnemySpecies); wallForce = new WallForce(WallRepulsionConstant, WallRepulsionExponent); flockForce = new FlockForce(FlockSpaceDistance, FlockSightDistance, FlockSpaceExponent, FlockExponent, FlockAlignExponent, FlockSpecies); }
/// <summary> /// Adds <paramref name="force"/> to the simulation. /// </summary> /// <param name="force">The <see cref="IForce"/> to add to the simulation.</param> /// <exception cref="ArgumentException"><paramref name="force"/> already exists.</exception> public void Add(IForce force) { if (!_forces.Add(force)) { throw new ArgumentException("Already exists.", nameof(force)); } }
public ArtificialIntelligence(World world, Boid self) : base(world, self) { enemyForce = new BoidAttractionForce(HunterAttractionConstant, HunterAttractionExponent, EnemySpecies); enemyForce1 = new BoidAttractionForce(HunterAttractionConstant, HunterAttractionExponent, EnemySpecies1); wallForce = new WallForce(WallRepulsionConstant, WallRepulsionExponent); }
public ForceEvaluation(IDecision decision, IForce force, IConcern concern, string result) { _decisionGUID = decision.GUID; Force = force; Concern = concern; Result = result; Decision = decision; }
public void AddForce(IForce Force) { if (forces == null) { forces = new List<IForce>(); } forces.Add(Force); }
public void AddForce(IForce Force) { if (forces == null) { forces = new List <IForce>(); } forces.Add(Force); }
//private const string ConcernUID = "ConcernUID"; //private const string Weight = "Weight"; //public void AddForce(IForce force, IConcern concern) //{ // var concernUID = force.AddConcern(this, concern); // if (concernUID != null) // { // var element = Element; // var forceElement = force.Element; // var forceConnector = element.ConnectTo(forceElement, EAConstants.ForcesConnectorType, EAConstants.ForcesConnectorType); // forceConnector.AddTaggedValue(ConcernUID, concernUID); // forceConnector.AddTaggedValue(Weight, string.Empty); // Forces.Add(new TopicForceEvaluation(this, force, concern, Decisions)); // } //} public IEnumerable <string> GetConcerns(IForce force) { var topicElement = EAMain.Repository.GetElementByGUID(GUID); return(from x in topicElement.GetConnectors() where x.MetaType.Equals(EAConstants.ForcesConnectorType) && x.GetSupplier().GUID.Equals(force.ForceGUID) && x.TaggedValueExists(EAConstants.ConcernUID) select x.GetTaggedValueByName(EAConstants.ConcernUID)); }
/// <summary> /// Initializes a new instance of the <see cref="ForceSet"/> class. /// </summary> public ForceSet( IForce <IParticle> forParticles, IForce <IBody <Polygon> > forBodies) { ArgumentChecks.AssertNotNull(forParticles, nameof(forParticles)); ArgumentChecks.AssertNotNull(forBodies, nameof(forBodies)); this.ForParticles = forParticles; this.ForBodies = forBodies; }
public void MoveByVector(IForce force) { if (force.VectorPosition.Dimension != Dimension) { throw new ArgumentException("Invalid dimension."); } for (int i = 0; i < Dimension; i++) { Coordinates[i] += force.VectorPosition[i]; } }
public void AddForce(IForce Force) { if (CombinationResults == null) { combinationResults = new List <ICombinationResult>(); CombinationResult result = new CombinationResult(null); combinationResults.Add(result); } ICombinationResult r = CombinationResults.ElementAt(0); r.AddForce(Force); }
public IForce FindMinimumForce(ForceType ForceType, bool IgnoreSign, ref string CombinationName) { double MinVal = double.PositiveInfinity; IForce cForce = null; double forceValue = 0.0; foreach (var combinationResult in CombinationResults) { foreach (var f in combinationResult.Forces) { switch (ForceType) { case ForceType.F1: forceValue = IgnoreSign == true?Math.Abs(f.F1) : f.F1; break; case ForceType.F2: forceValue = IgnoreSign == true?Math.Abs(f.F2) : f.F2; break; case ForceType.F3: forceValue = IgnoreSign == true?Math.Abs(f.F3) : f.F3; break; case ForceType.M1: forceValue = IgnoreSign == true?Math.Abs(f.M1) : f.M1; break; case ForceType.M2: forceValue = IgnoreSign == true?Math.Abs(f.M2) : f.M2; break; case ForceType.M3: forceValue = IgnoreSign == true?Math.Abs(f.M3) : f.M3; break; } if (forceValue < MinVal) { MinVal = forceValue; CombinationName = combinationResult.CombinationName; cForce = f; } } } return(cForce); }
public Builder AddForce(string name, IForce force) { if (name == null || force == null) { return(this); } if (forces == null) { forces = new Dictionary <string, IForce>(10); } forces.Add(name, force); return(this); }
// Use this for initialization void Start() { this.particles = new DEMParticles(); this.spacePartitioner = new GridSP<int>( boundBL, boundTR, 20, 20, new IntEqualityComparer()); this.gravitationalForce = new GravitationalForce(new Vector2(0, -9.8f)); this.boundaryForce = new BoundaryForce( kn, cn, boundBL.x, boundBL.y, boundTR.x, boundTR.y); this.dem = new DEM(spacePartitioner, gravitationalForce, boundaryForce); spheres = new GameObject[nParticles]; for (int i = 0; i < nParticles; i++) { GameObject s = GameObject.CreatePrimitive(PrimitiveType.Sphere); s.transform.localScale = new Vector3(diameter, diameter, diameter); s.transform.position = new Vector3( Random.Range(boundBL.x, boundTR.x), Random.Range(boundBL.y, boundTR.y), 0); Destroy(s.collider); spheres[i] = s; } int length = spheres.Length; float[] radii = new float[length]; float[] masses = new float[length]; Vector2[] positions = new Vector2[length]; Vector2[] velocities = new Vector2[length]; for (int i = 0; i < length; i++) { GameObject sphere = spheres[i]; float radius = 0.5f * sphere.transform.localScale.x; radii[i] = radius; masses[i] = mass; //(rho * Mathf.PI * radius); positions[i] = new Vector2( sphere.transform.position.x, sphere.transform.position.y); velocities[i] = Vector2.zero; } particles.addParticle(masses, radii, positions, velocities); for (int i = 0; i < length; i++) { spacePartitioner.add(particles.buildAABB(i), i); } }
public TopicForceEvaluation(ITopic topic, IForce force, IConcern concern, IEnumerable <IDecision> decisions) { Force = force; Concern = concern; DecisionEvaluations = new BindingList <DecisionEvaluation>(); Topic = topic; var connector = GetTopicForceConnector(Topic.Element); if (connector == null) { Changed = true; //new force so must be saved } Weight = connector == null ? string.Empty : connector.GetTaggedValueByName(EAConstants.ForceWeight); foreach (var decision in decisions) { DecisionEvaluations.Add(new DecisionEvaluation(decision, Concern, Force)); } PropertyChanged += OnPropertyChanged; DecisionEvaluations.RaiseListChangedEvents = true; DecisionEvaluations.ListChanged += DecisionEvaluationsOnListChanged; }
public void AddForce(string CombinationName, IForce Force) { IEnumerable <ICombinationResult> comboQuery = combinationResults.Where(cr => cr.CombinationName == CombinationName); if (comboQuery.Count() == 0) { CombinationResult result = new CombinationResult(CombinationName); result.Forces.Add(Force); } else { if (comboQuery.Count() > 1) { throw new Exception("More than 1 combination with that name detected."); } else { ICombinationResult r = comboQuery.ElementAt(0); r.Forces.Add(Force); } } }
public ArtificialIntelligence(World world, Boid self) : base(world, self) { secondfriendForce = new BoidAttractionForce(HunterAttractionConstant, HunterAttractionExponent, SecondFriendSpecies); friendForce = new BoidAttractionForce(PreyAttractionConstant, PreyAttractionExponent, FriendSpecies); }
/// <summary> /// Adds a custom force to the force simulation. /// </summary> /// <param name="force">the force to add</param> public void AddForce(IForce force) { _forces.Add(force); }
public InteractionsHandler Add <T>(IForce <T> force, List <T> entities) { return(Add(new Interaction <T>(force, entities))); }
/// <summary> /// /// </summary> /// <param name="abbreviation"></param> /// <param name="force"></param> /// <param name="length"></param> protected EnergyBase(string abbreviation, IForce force, ILength length) : base(abbreviation, force, length) { VerifyDimensions(); }
public RemoveForceRequest(GameObjectBase gameObject, IForce force) { GameObject = gameObject; Force = force; }
private void ApplyForce(INode node, IForce force) { node.Position.MoveByVector(force); }
public void AddForceField(IForce force) { forces.Add(force); }
public void addGlobalForce(IForce force) { _globalForces.Add(force); _applyGlobalForce(force); }
public void AddGlobalForce(IForce force) { globalForces.Add(force); }
public ForceEvaluation(ITopic topic, IForce force, IConcern concern, string result) { Concern = concern; Result = result; Force = Force; }
public InputAttackController(BulletFactory bulletFactory, IForce force, IPoolSize poolSize) { _force = force; _capacityPool = poolSize; _bulletPool = new BulletPool(bulletFactory, _capacityPool.PoolSize); }
public Interaction(IForce <T> force, List <T> entities) { Force = force; Entities = entities; }
public void AddForce(IForce force) { ForceObjects.Add(force); }
private Energy(string abbreviation, IForce force, ILength length) : base(abbreviation, force, length) { }
void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); parentForce = gameObject.GetComponentInParent <IForce>(); }
public void RemoveForce(IForce force) { ForceObjects.Remove(force); }