return reversed;
}
+ public boolean _getReversed() {
+ if (reversed == null)
+ return false;
+ return reversed;
+ }
+
public void setTurnAngle(Double turnAngle) {
if (Double.isInfinite(turnAngle) || Double.isNaN(turnAngle)) {
return;
public void setReversed(Boolean reversed) {
this.reversed = reversed;
- firePropertyChanged("rotationAngle");
+ firePropertyChanged("reversed");
}
public Vector3d getSizeChangeOffsetVector(Vector3d dir) {
return q1;
}
- public Vector3d getDirection() {
- return getDirectedControlPointDirection();
+ public Vector3d getDirection(Direction direction) {
+ if (isDirected())
+ return getDirectedControlPointDirection();
+ if (isTurn() && isFixed()) {
+ if (direction == Direction.NEXT) {
+ if (previous != null) {
+ PipeControlPoint pcp = this;
+ Vector3d dir = new Vector3d();
+ dir.sub(pcp.getWorldPosition(),previous.getWorldPosition());
+ if (dir.lengthSquared() > MathTools.NEAR_ZERO)
+ dir.normalize();
+ Quat4d q = getControlPointOrientationQuat(dir, pcp.getRotationAngle() != null ? pcp.getRotationAngle() : 0.0);
+ AxisAngle4d aa = new AxisAngle4d(MathTools.Y_AXIS,pcp.getTurnAngle() == null ? 0.0 : pcp.getTurnAngle());
+ Quat4d q2 = MathTools.getQuat(aa);
+ Vector3d v = new Vector3d(1.,0.,0.);
+ Vector3d offset = new Vector3d();
+ MathTools.rotate(q2, v, offset);
+ MathTools.rotate(q, offset, dir);
+ return dir;
+ }
+ } else {
+ if (next != null) {
+ PipeControlPoint pcp = this;
+ Vector3d dir = new Vector3d();
+ dir.sub(next.getWorldPosition(),pcp.getWorldPosition());
+ if (dir.lengthSquared() > MathTools.NEAR_ZERO)
+ dir.normalize();
+ Quat4d q = getControlPointOrientationQuat(dir, pcp.getRotationAngle() != null ? pcp.getRotationAngle() : 0.0);
+ AxisAngle4d aa = new AxisAngle4d(MathTools.Y_AXIS,pcp.getTurnAngle() == null ? 0.0 : pcp.getTurnAngle());
+ Quat4d q2 = MathTools.getQuat(aa);
+ Vector3d v = new Vector3d(1.,0.,0.);
+ Vector3d offset = new Vector3d();
+ MathTools.rotate(q2, v, offset);
+ MathTools.rotate(q, offset, dir);
+ return dir;
+ }
+ }
+ }
+ return null;
}
-
-
-
-
-
-
public void insert(PipeControlPoint previous, PipeControlPoint next) {
// inserting an offsetpoint is error,
if (isDualSub())
- throw new RuntimeException();
+ throw new RuntimeException("Dual sub points cannot be inserted.");
// size change control point cannot be inserted this way, because it ends PipeRun
if (isSizeChange())
- throw new RuntimeException();
+ throw new RuntimeException("Size change points cannot be inserted.");
PipeRun piperun = previous.getPipeRun();
// and just to make sure that control point structure is not corrupted
if (getPipeRun() != null) {
if (piperun != getPipeRun() || piperun != next.getPipeRun())
- throw new RuntimeException();
+ throw new RuntimeException("All controls points must be located on the same pipe run");
} else {
piperun.addChild(this);
}
v.sub(next.getWorldPosition(),pcp.getWorldPosition());
return v;
} else {
- if (isVariableAngle())
- throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point");
if (previous == null) {
if (!isDirected())
throw new RuntimeException("Cannot calculate path leg direction for unconnected control point");
return getDirectedControlPointDirection();
} else {
+ if (isVariableAngle())
+ throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point");
if (isInline()) {
PipeControlPoint pcp = this;
if (pcp.isDualSub()) {
Vector3d v = new Vector3d();
v.sub(getWorldPosition(),previous.getWorldPosition());
return v;
+ } else if (isTurn() && isFixed() && !_getReversed()) {
+ return getDirection(Direction.NEXT);
}
throw new RuntimeException("Missing implementation");
}
v.sub(previous.getWorldPosition(),pcp.getWorldPosition());
return v;
} else {
- if (isVariableAngle())
- throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point");
if (next == null) {
if (!isDirected())
throw new RuntimeException("Cannot calculate path leg direction for unconnected control point");
v.negate();
return v;
} else {
- if (isInline()) {
+ if (isVariableAngle())
+ throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point");
+ if (isInline()) {
PipeControlPoint pcp = this;
if (pcp.isDualInline()) {
pcp = pcp.getSubPoint().get(0);
Vector3d v = new Vector3d();
v.sub(getWorldPosition(),next.getWorldPosition());
return v;
- }
+ } else if (isTurn() && isFixed() && _getReversed()) {
+ return getDirection(Direction.PREVIOUS);
+ }
throw new RuntimeException("Missing implementation");
}
}