Archive Browser
Download ChemotaxisSimulation.zip, last updated 02/11/2020 (529.88 KB)
Download- md5: d0f0a74f8f3c043fabf60aeb07356f69
- sha1: 645a77d0f7184873fe70c2bb375833e564b348be
- sha256: da9ab3cfc5e17e120b6660a137012b6eca68a7a3218cb213b3e0e3eb9445b104
using System;
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
{
internal static class Geometry
{
#region Public Methods
public static bool DoesPointIntersectCircle(Point point, Point center, float radius)
{
return Geometry.DoesPointIntersectCircle(point.X, point.Y, center.X, center.Y, radius);
}
public static bool DoesPointIntersectCircle(float x, float y, float cx, float cy, float radius)
{
return Geometry.GetDistance(x, y, cx, cy) < radius;
}
public static double GetDistance(float x1, float y1, float x2, float y2)
{
float dx;
float dy;
dx = x1 - x2;
dy = y1 - y2;
return Math.Sqrt((dx * dx) + (dy * dy));
}
public static int GetDistance(int x1, int y1, int x2, int y2)
{
float dx;
float dy;
dx = x1 - x2;
dy = y1 - y2;
return (int)Math.Sqrt((dx * dx) + (dy * dy));
}
public static int GetDistance(Point p1, Point p2)
{
return Geometry.GetDistance(p1.X, p1.Y, p2.X, p2.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