Strand strand = new Strand();
strand.vertices = new Point3[2 * (segments + 1)];
strand.emitterContext = context;
strand.strandIndex = index;
Point3 pos = context.getPosition();
Vector3 vel = context.getBasis().toStandard(meanInitialVelocity).plus(
RandomUtil.uniformInsideSphere(randomInitialVelocity, adapter)
.toCartesian());
double dt = 1.0 / (double) segments;
double orientation = 2.0 * Math.PI * rnd.nextDouble();
double co = Math.cos(orientation);
double so = Math.sin(orientation);
Basis3 basis = Basis3.fromWU(vel, context.getTangent());
int segment = 0;
int i = 0;
while (true) {
double t = (double) segment / (double) segments;
double width = MathUtil.interpolate(baseWidth, tipWidth, t);
strand.vertices[i++] = pos.plus(basis.toStandard(-0.5 * width * co, -0.5 * width * so, 0.0));
strand.vertices[i++] = pos.plus(basis.toStandard(0.5 * width * co, 0.5 * width * so, 0.0));
if (++segment > segments) {
break;
}
pos = pos.plus(vel.times(dt));
pos = pos.plus(RandomUtil.uniformInsideSphere(roughness, adapter).toCartesian());
}
return strand;
}