Create Transition::calculateProperties() to update component properties as needed instead of recalculating for shoulders every time they're called.
This commit is contained in:
parent
4dd2c3a86a
commit
b5b3ac2b3d
@ -32,11 +32,11 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou
|
|||||||
private double wetArea = Double.NaN;
|
private double wetArea = Double.NaN;
|
||||||
private double planArea = Double.NaN;
|
private double planArea = Double.NaN;
|
||||||
private double planCenter = Double.NaN;
|
private double planCenter = Double.NaN;
|
||||||
private double volume = Double.NaN;
|
protected double volume = Double.NaN;
|
||||||
private double fullVolume = Double.NaN;
|
private double fullVolume = Double.NaN;
|
||||||
private double longitudinalInertia = Double.NaN;
|
private double longitudinalInertia = Double.NaN;
|
||||||
private double rotationalInertia = Double.NaN;
|
private double rotationalInertia = Double.NaN;
|
||||||
private Coordinate cg = null;
|
protected Coordinate cg = null;
|
||||||
|
|
||||||
public SymmetricComponent() {
|
public SymmetricComponent() {
|
||||||
super();
|
super();
|
||||||
@ -417,7 +417,7 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou
|
|||||||
/**
|
/**
|
||||||
* Performs integration over the length of the component and updates the cached variables.
|
* Performs integration over the length of the component and updates the cached variables.
|
||||||
*/
|
*/
|
||||||
private void calculateProperties() {
|
protected void calculateProperties() {
|
||||||
wetArea = 0;
|
wetArea = 0;
|
||||||
planArea = 0;
|
planArea = 0;
|
||||||
planCenter = 0;
|
planCenter = 0;
|
||||||
|
@ -671,58 +671,46 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getComponentVolume() {
|
protected void calculateProperties() {
|
||||||
double volume = super.getComponentVolume();
|
super.calculateProperties();
|
||||||
if (getForeShoulderLength() > 0.001) {
|
if (getForeShoulderLength() > 0.001) {
|
||||||
final double or = getForeShoulderRadius();
|
final double or = getForeShoulderRadius();
|
||||||
final double ir = Math.max(getForeShoulderRadius() - getForeShoulderThickness(), 0);
|
final double ir = Math.max(getForeShoulderRadius() - getForeShoulderThickness(), 0);
|
||||||
volume += ringVolume( or, ir, getForeShoulderLength() );
|
|
||||||
}
|
|
||||||
if (isForeShoulderCapped()) {
|
|
||||||
final double ir = Math.max(getForeShoulderRadius() - getForeShoulderThickness(), 0);
|
|
||||||
volume += ringVolume(ir, 0, getForeShoulderThickness() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getAftShoulderLength() > 0.001) {
|
|
||||||
final double or = getAftShoulderRadius();
|
|
||||||
final double ir = Math.max(getAftShoulderRadius() - getAftShoulderThickness(), 0);
|
|
||||||
volume += ringVolume(or, ir, getAftShoulderLength() );
|
|
||||||
}
|
|
||||||
if (isAftShoulderCapped()) {
|
|
||||||
final double ir = Math.max(getAftShoulderRadius() - getAftShoulderThickness(), 0);
|
|
||||||
volume += ringVolume(ir, 0, getAftShoulderThickness() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Coordinate getComponentCG() {
|
|
||||||
Coordinate cg = super.getComponentCG();
|
|
||||||
if (getForeShoulderLength() > 0.001) {
|
|
||||||
final double ir = Math.max(getForeShoulderRadius() - getForeShoulderThickness(), 0);
|
|
||||||
cg = cg.average(ringCG(getForeShoulderRadius(), ir, -getForeShoulderLength(), 0,
|
cg = cg.average(ringCG(getForeShoulderRadius(), ir, -getForeShoulderLength(), 0,
|
||||||
getMaterial().getDensity()));
|
getMaterial().getDensity()));
|
||||||
|
|
||||||
|
volume += ringVolume( or, ir, getForeShoulderLength() );
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isForeShoulderCapped()) {
|
if (isForeShoulderCapped()) {
|
||||||
final double ir = Math.max(getForeShoulderRadius() - getForeShoulderThickness(), 0);
|
final double ir = Math.max(getForeShoulderRadius() - getForeShoulderThickness(), 0);
|
||||||
cg = cg.average(ringCG(ir, 0, -getForeShoulderLength(),
|
cg = cg.average(ringCG(ir, 0, -getForeShoulderLength(),
|
||||||
getForeShoulderThickness() - getForeShoulderLength(),
|
getForeShoulderThickness() - getForeShoulderLength(),
|
||||||
getMaterial().getDensity()));
|
getMaterial().getDensity()));
|
||||||
|
|
||||||
|
volume += ringVolume(ir, 0, getForeShoulderThickness() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAftShoulderLength() > 0.001) {
|
if (getAftShoulderLength() > 0.001) {
|
||||||
|
final double or = getAftShoulderRadius();
|
||||||
final double ir = Math.max(getAftShoulderRadius() - getAftShoulderThickness(), 0);
|
final double ir = Math.max(getAftShoulderRadius() - getAftShoulderThickness(), 0);
|
||||||
|
|
||||||
cg = cg.average(ringCG(getAftShoulderRadius(), ir, getLength(),
|
cg = cg.average(ringCG(getAftShoulderRadius(), ir, getLength(),
|
||||||
getLength() + getAftShoulderLength(), getMaterial().getDensity()));
|
getLength() + getAftShoulderLength(), getMaterial().getDensity()));
|
||||||
|
|
||||||
|
volume += ringVolume(or, ir, getAftShoulderLength() );
|
||||||
}
|
}
|
||||||
if (isAftShoulderCapped()) {
|
if (isAftShoulderCapped()) {
|
||||||
|
final double or = getAftShoulderRadius();
|
||||||
final double ir = Math.max(getAftShoulderRadius() - getAftShoulderThickness(), 0);
|
final double ir = Math.max(getAftShoulderRadius() - getAftShoulderThickness(), 0);
|
||||||
|
|
||||||
cg = cg.average(ringCG(ir, 0,
|
cg = cg.average(ringCG(ir, 0,
|
||||||
getLength() + getAftShoulderLength() - getAftShoulderThickness(),
|
getLength() + getAftShoulderLength() - getAftShoulderThickness(),
|
||||||
getLength() + getAftShoulderLength(), getMaterial().getDensity()));
|
getLength() + getAftShoulderLength(), getMaterial().getDensity()));
|
||||||
|
|
||||||
|
volume += ringVolume(ir, 0, getAftShoulderThickness() );
|
||||||
}
|
}
|
||||||
return cg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user