Game Development Reference
In-Depth Information
// Get some initial quantities from the text fields.
double velocity = Double.parseDouble(velocityTextField.getText());
double density = Double.parseDouble(densityTextField.getText());
distanceToHole = Double.parseDouble(distanceTextField.getText());
double windVx = Double.parseDouble(windVxTextField.getText());
double windVy = Double.parseDouble(windVyTextField.getText());
double rx = Double.parseDouble(rxTextField.getText());
double ry = Double.parseDouble(ryTextField.getText());
double rz = Double.parseDouble(rzTextField.getText());
The club head mass and loft angle are set according to the club the user has selected.
The mass and angle values are those shown in Table 7-2.
// Set the club mass and loft based on the combo box
// selection.
double clubMass;
double loft;
String club = (String)clubComboBox.getSelectedItem();
if ( club.equals("Driver") ) {
clubMass = 0.2;
loft = 11.0;
}
else if ( club.equals("3 wood") ) {
clubMass = 0.208;
loft = 15.0;
}
else if ( club.equals("3 iron") ) {
clubMass = 0.239;
loft = 21.0;
}
else if ( club.equals("5 iron") ) {
clubMass = 0.253;
loft = 27.0;
}
else if ( club.equals("7 iron") ) {
clubMass = 0.267;
loft = 35.0;
}
else {
clubMass = 0.281;
loft = 43.0;
}
The method then computes the post-collision velocities in the x- and z-directions for the
golf ball according to the process outlined in the “A Sample Collision Analysis” presented
earlier in the chapter.
Search WWH ::




Custom Search