public class Spring extends Object implements Serializable
Points it may interconnect.| Modifier and Type | Field and Description |
|---|---|
protected double |
length |
protected double |
maxStretch |
protected static Random |
rnd |
protected double |
weight |
protected double[] |
weights |
| Constructor and Description |
|---|
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)
|
Spring(Point p1,
Point p2,
double weight)
|
Spring(Point p1,
Point p2,
double[] weights)
|
Spring(Point p1,
Point p2,
double[] weights,
double maxStretch)
|
Spring(Point p1,
Point p2,
double weight,
double maxStretch)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWeight(double w) |
void |
calculateForce(Point p1,
Point p2,
double[] force)
|
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) |
protected static final Random rnd
protected double length
protected final double maxStretch
protected double[] weights
protected double weight
public Spring(double length,
double[] weights)
Spring with an Array of weights.
The Array of weights will be copied.length - weights - Array of weightspublic Spring(double length,
double[] weights,
double maxStretch)
Spring with an Array of weights.
The Array of weights will be copied.length - weights - Array of weightsmaxStretch - stretch limitpublic Spring(double length,
double weight)
Spring with one weight.length - weight - (spring constant)public Spring(double length,
double weight,
double maxStretch)
Spring with one weight.length - weight - (spring constant)maxStretch - stretch limitpublic Spring(double length)
Spring without weight.length - public Spring(Point p1, Point p2, double[] weights)
Spring between two Points with an
Array of weights. The Array of weights will be copied.p1 - Point 1p2 - Point 2weights - Array of weightspublic Spring(Point p1, Point p2, double[] weights, double maxStretch)
Spring between two Points with an
Array of weights. The Array of weights will be copied.p1 - Point 1p2 - Point 2weights - Array of weightsmaxStretch - stretch limitpublic Spring(Point p1, Point p2, double weight)
p1 - Point 1p2 - Point 2weight - Weightpublic Spring(Point p1, Point p2, double weight, double maxStretch)
p1 - Point 1p2 - Point 2weight - WeightmaxStretch - stretch limitpublic double getLength()
public void setLength(double length)
protected static double squareLength(double[] p1,
double[] p2)
protected static double length(double[] p1,
double[] p2)
protected void calculateWeight()
public double getWeight()
public double[] getWeights()
public void setWeights(double[] weights)
public void addWeight(double w)
public void removeWeight(int index)
public void setWeight(int index,
double weight)
Copyright © 2015–2021 Fiji. All rights reserved.