Archive Browser
Download ChemotaxisSimulation.zip, last updated 02/11/2020 (529.88 KB)
Download- md5: d0f0a74f8f3c043fabf60aeb07356f69
- sha1: 645a77d0f7184873fe70c2bb375833e564b348be
- sha256: da9ab3cfc5e17e120b6660a137012b6eca68a7a3218cb213b3e0e3eb9445b104
using System.Drawing;
// Simulating Bacterial Chemotaxis
// https://www.cyotek.com/blog/simulating-bacterial-chemotaxis
// Copyright © 2020 Cyotek Ltd. All Rights Reserved.
// This work is licensed under the MIT License.
// See LICENSE.TXT for the full text
// Found this example useful?
// https://www.paypal.me/cyotek
namespace Cyotek.ChemotaxisSimulation
{
public class Chemoeffector
{
#region Private Fields
private Point _heading;
private Simulation _owner;
private Point _position;
private int _strength;
#endregion Private Fields
#region Public Properties
public Point Heading
{
get { return _heading; }
set { _heading = value; }
}
public Point Position
{
get { return _position; }
set { _position = value; }
}
public int Strength
{
get { return _strength; }
set { _strength = value; }
}
#endregion Public Properties
#region Internal Properties
internal Simulation Owner
{
get { return _owner; }
set { _owner = value; }
}
#endregion Internal Properties
#region Public Methods
public void Move()
{
if (!_heading.IsEmpty)
{
int x;
int y;
x = _position.X + _heading.X;
y = _position.Y + _heading.Y;
if (x < 0 || y < 0 || x > _owner.Size.Width - 1 || y > _owner.Size.Height)
{
if (_owner.Wrap)
{
if (x < 0)
{
x = _owner.Size.Width - 1;
}
else if (x > _owner.Size.Width - 1)
{
x = 1;
}
if (y < 0)
{
y = _owner.Size.Height - 1;
}
else if (y > _owner.Size.Height - 1)
{
y = 1;
}
_position = new Point(x, y);
}
else
{
_heading = Compass.GetOpposite(_heading);
}
}
else
{
_position = new Point(x, y);
}
}
}
#endregion Public Methods
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate