}
/**
- * Returns direction vector.
+ * Returns direction vector pointing towards an adjacent component for
+ * directed control points or turn control points with one open end.
*
- * For directed control points, always returns outwards pointing vector.
+ * Always returns an outwards pointing vector.
+ *
+ * For any other type of component, the return value is null.
+ *
+ * For turn components this only return a non-null value for the unconnected
+ * end of the component.
*
* @param direction
* @return normalized vector, or null
Vector3d offset = new Vector3d();
MathTools.rotate(q2, v, offset);
MathTools.rotate(q, offset, dir);
+ dir.negate();
dir.normalize();
return dir;
}
sizeChange = ((InlineComponent)newComponent).isSizeChange();
}
+ // Calculate component position and direction vectors
+ // 'dir' is a unit vector that represents the direction from 'component' to 'newComponent'
if (toPcp.isInline()) {
switch (position) {
case NEXT:
break;
case PREVIOUS:
pos = new Vector3d(start);
+ dir.negate();
break;
case SPLIT:
pos = new Vector3d(toPcp.getWorldPosition());
default:
break;
}
-
} else if (toPcp.isDirected()) {
- dir = new Vector3d(toPcp.getDirection(Direction.NEXT));
- if (position == PositionType.PREVIOUS)
- dir.negate();
+ // 'dir' always points out of a nozzle regardless of insertion direction
+ dir = new Vector3d(toPcp.getDirectedControlPointDirection());
pos = new Vector3d(toPcp.getWorldPosition());
} else if (toPcp.isTurn() && toPcp.asFixedAngle()) {
dir = new Vector3d(toPcp.getDirection(position == PositionType.NEXT ? Direction.NEXT : Direction.PREVIOUS));
((TurnComponent) newComponent).setRotationAngle(inst.rotationAngle);
}
-
newComponent.updateParameters();
Vector3d v = new Vector3d(dir);
} else {
v.scale(newComponent.getControlPoint().getInlineLength());
}
+
switch (position) {
case NEXT:
- pos.add(v);
- break;
case PREVIOUS:
- pos.sub(v);
+ pos.add(v);
break;
case SPLIT:
break;