Example #1
0
  public void run() {

    PhysicalCylinder cyl = (PhysicalCylinder) cellElement.getPhysical();

    // Juste temporary for getting a picture :
    //		if(cyl.getMassLocation()[2]<-100){
    //			return;
    //		}

    double lengthBefore = cyl.getLength();
    // not to thin?
    if (cyl.getDiameter() < minimalBranchDiameter) {
      if (cyl.lengthToProximalBranchingPoint()
          > 7 + 10 * ECM.getRandomDouble()) { // so we don't end with short segments
        return;
      }
    }

    // can't leave
    if (cantLeave != null) {
      double currentCantLeaveConcntration = cyl.getExtracellularConcentration(cantLeave);
      if (currentCantLeaveConcntration > maxConcentration) {
        maxConcentration = currentCantLeaveConcntration;
      }
      if (currentCantLeaveConcntration < 0.95 * maxConcentration) {
        cyl.setColor(Color.black);
        return;
      }
    }

    // find the gradients
    double[] totalGradient = {0.0, 0.0, 0.0};
    for (String s : attractants) {
      double[] normalizedGrad = normalize(cyl.getExtracellularGradient(s));
      totalGradient = add(totalGradient, normalizedGrad);
    }
    for (String s : repellents) {
      double[] normalizedAntiGrad = scalarMult(-1.0, normalize(cyl.getExtracellularGradient(s)));
      totalGradient = add(totalGradient, normalizedAntiGrad);
    }
    // if no gradient : go straight
    if (attractants.isEmpty() && repellents.isEmpty()) {
      totalGradient = movementDirection;
    }

    double[] newStepDirection =
        add(
            movementDirection,
            scalarMult(directionWeight, totalGradient),
            randomNoise(randomness, 3));

    cyl.movePointMass(speed, newStepDirection);

    movementDirection = normalize(add(scalarMult(5, movementDirection), newStepDirection));

    // decrease diameter setDiameter
    double lengthAfter = cyl.getLength();
    double deltaL = lengthAfter - lengthBefore;
    if (deltaL < 0) deltaL = 0;
    cyl.setDiameter(cyl.getDiameter() * (1 - deltaL * linearDiameterDecrease));
  }
Example #2
0
 public void setCellElement(CellElement cellElement) {
   this.cellElement = cellElement;
   this.movementDirection = cellElement.getPhysical().getXAxis();
 }