protected void CalculateNextLocation(IPointAdapter location)
    {
        float dX = v * dT * MathFloat.Cos(angle), dZ = v * dT * MathFloat.Sin(angle);

        while (location.GetX() + dX > 14 || location.GetX() + dX < -14 || location.GetZ() + dZ > 14 || location.GetZ() + dZ < -14)
        {
            angle = CalculateTumbleAngle();
            dX    = v * dT * MathFloat.Cos(angle);
            dZ    = v * dT * MathFloat.Sin(angle);
        }
        location.Add(dX, dZ);
    }
Example #2
0
    private Vector3Adapter CalculateNextPoint(float x, float z, AbstractEnvironment environment)
    {
        //calculates the angle that the cell should move towards based on the ligand gradient
        float alfa   = MathFloat.Atan2(environment.GradZ(x, z), environment.GradX(x, z));
        float factor = 1 - smartnessFactor;

        //calculates the x and z delta based on the angle and the sampled value
        float dx = MathFloat.Cos(alfa) * dT * v + (float)Normal.Sample(0.0, v * dT * factor);
        float dz = MathFloat.Sin(alfa) * dT * v + (float)Normal.Sample(0.0, v * dT * factor);

        //adds the delta to the x and z cords while making sure that it does not move outside the dish
        x = MathFloat.Clamp(x + dx, -14, 14);
        z = MathFloat.Clamp(z + dz, -14, 14);

        //create the new point
        return(new Vector3Adapter(x, z));
    }