# Given a location, heading, and a step size, how do I determine the resulting location of the next step?

I would like to develop an application where a cylinder shape moves a constant speed at a given heading over time. The user could update that heading via keyboard input, at which point the cylinder would move in the new heading.

I am having issues with the math of calculating the cylinder's next position. Given a location, heading, and a step size, how do I determine the resulting location of the next step? What are the java 3d classes I should be using to make this calculation?

I presume that much of the work will be done via transform3d instances. The heading might be a transform3d whose heading values could be tweaked by calling the transform3d's rotX, rotY, and rotY methods. The shape object transform would store the current location. How do I calculate the next location after the step?

`private void calculateNextStep(TransformGroup shapeGroup, double xAngle, double yAngle, double zAngle, double stepSize) {`

Transform3D shapeTransform = new Transform3D();

shapeGroup.getTransform(shapeTransform);Transform3D headingTransform = new Transform3D();

headingTransform.rotX(xAngle);

headingTransform.rotY(yAngle);

headingTransform.rotZ(zAngle);

// how do I apply the stepsize and heading onto the shape?

// ...

}

<br type="_moz" />

Thanks in advance