mpicbg.models
Class Spring

java.lang.Object
  extended by mpicbg.models.Spring
All Implemented Interfaces:
Serializable

public class Spring
extends Object
implements Serializable

A simple spring model. Instances represent the actual spring only, not the Points it may interconnect.

Author:
Stephan Saalfeld
See Also:
Serialized Form

Field Summary
protected  double length
           
protected  double maxStretch
           
protected static Random rnd
           
protected  double weight
           
protected  double[] weights
           
 
Constructor Summary
Spring(double length)
          Constructor Create a Spring without weight.
Spring(double length, double weight)
          Constructor Create a Spring with one weight.
Spring(double length, double[] weights)
          Constructor Create a Spring with an Array of weights.
Spring(double length, double[] weights, double maxStretch)
          Constructor Create a Spring with an Array of weights.
Spring(double length, double weight, double maxStretch)
          Constructor Create a Spring with one weight.
Spring(Point p1, Point p2)
          Constructor Create a Spring between two Points without weight.
Spring(Point p1, Point p2, double weight)
          Constructor Create a Spring between two Points with one weight.
Spring(Point p1, Point p2, double[] weights)
          Constructor Create a Spring between two Points with an Array of weights.
Spring(Point p1, Point p2, double[] weights, double maxStretch)
          Constructor Create a Spring between two Points with an Array of weights.
Spring(Point p1, Point p2, double weight, double maxStretch)
          Constructor Create a Spring between two Points with one weight.
 
Method Summary
 void addWeight(double w)
           
 void calculateForce(Point p1, Point p2, double[] force)
          Estimate the force vector effective to p1 if this Spring would connect both Vertices.
protected  void calculateWeight()
           
 double getLength()
           
 double getWeight()
           
 double[] getWeights()
           
protected static double length(double[] p1, double[] p2)
           
 void removeWeight(int index)
           
 void setLength(double length)
           
 void setWeight(int index, double weight)
           
 void setWeights(double[] weights)
           
protected static double squareLength(double[] p1, double[] p2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rnd

protected static final Random rnd

length

protected double length

maxStretch

protected final double maxStretch

weights

protected double[] weights

weight

protected double weight
Constructor Detail

Spring

public Spring(double length,
              double[] weights)
Constructor Create a Spring with an Array of weights. The Array of weights will be copied.

Parameters:
length -
weights - Array of weights

Spring

public Spring(double length,
              double[] weights,
              double maxStretch)
Constructor Create a Spring with an Array of weights. The Array of weights will be copied.

Parameters:
length -
weights - Array of weights
maxStretch - stretch limit

Spring

public Spring(double length,
              double weight)
Constructor Create a Spring with one weight.

Parameters:
length -
weight - (spring constant)

Spring

public Spring(double length,
              double weight,
              double maxStretch)
Constructor Create a Spring with one weight.

Parameters:
length -
weight - (spring constant)
maxStretch - stretch limit

Spring

public Spring(double length)
Constructor Create a Spring without weight.

Parameters:
length -

Spring

public Spring(Point p1,
              Point p2,
              double[] weights)
Constructor Create a Spring between two Points with an Array of weights. The Array of weights will be copied.

Parameters:
p1 - Point 1
p2 - Point 2
weights - Array of weights

Spring

public Spring(Point p1,
              Point p2,
              double[] weights,
              double maxStretch)
Constructor Create a Spring between two Points with an Array of weights. The Array of weights will be copied.

Parameters:
v1 - Point 1
v2 - Point 2
weights - Array of weights
maxStretch - stretch limit

Spring

public Spring(Point p1,
              Point p2,
              double weight)
Constructor Create a Spring between two Points with one weight.

Parameters:
p1 - Point 1
p2 - Point 2
weight - Weight

Spring

public Spring(Point p1,
              Point p2,
              double weight,
              double maxStretch)
Constructor Create a Spring between two Points with one weight.

Parameters:
p1 - Point 1
p2 - Point 2
weight - Weight
maxStretch - stretch limit

Spring

public Spring(Point p1,
              Point p2)
Constructor Create a Spring between two Points without weight.

Parameters:
p1 - Point 1
p2 - Point 2
Method Detail

getLength

public double getLength()

setLength

public void setLength(double length)

squareLength

protected static double squareLength(double[] p1,
                                     double[] p2)

length

protected static double length(double[] p1,
                               double[] p2)

calculateWeight

protected void calculateWeight()

getWeight

public double getWeight()

getWeights

public double[] getWeights()

setWeights

public void setWeights(double[] weights)

addWeight

public void addWeight(double w)

removeWeight

public void removeWeight(int index)

setWeight

public void setWeight(int index,
                      double weight)

calculateForce

public void calculateForce(Point p1,
                           Point p2,
                           double[] force)
Estimate the force vector effective to p1 if this Spring would connect both Vertices.

Parameters:
p1 -
p2 -
force -


Copyright © 2007-2016 Fiji. All Rights Reserved.