Ball curve on hits

## Summary

There are 4 components contributing to the degree of curve a ball has.

* **Contact Spot**: the closer to perfect contact, the more curve the ball will have. Characters with the Super-Curve attribute get a boost to this factor.
* **Launch angle**: The curve starts to decrease once the launch angle is above 33.75 degrees, constantly decreasing until 78.75 degrees, at which point there will be no curve.
* **Horizontal angle**: this determines which direction the curve will go, and its magnitude. The point at which the curve direction flips is at 8.4 degrees to the batters pull side. The further away the ball is from this point, the more dramatic the curve is.
* **Super-curve**: Each ball hit has some degree of curve, but the characters with super-curve have a higher curve factor.

All of the quantities above are multiplied together to get the acceleration in the x and z direction. The sign of the accelerations are adjusted to match the left-right polarity determined from the horizontal angle, and the z curve is always set to be back towards home plate.

## Full Algorithm

This is the full algorithm for determining the ball acceleration on hits.

### Determine each component velocity

Use sin and cos to arrive at the relative values each direction has. For the purposes of this calculation, the origin of the angles begins at straight right, ad 90 degrees is pointed towards 2B.

y velocity = sin(launch angle) \* half exit velocity

ground velocity = cos(vertical angle) \* half exit velocity

x velocity = cos(horizontal angle) \* ground velocity

z velocity = sin(horizontal angle) \* ground velocity

Divide the above velocities by 100 when using them in subsequent calculations.

### Determine each component acceleration

These values are the initial accelerations - the effects due to gravity and air resistance are applied later.

#### **y acceleration**

This is set from the added gravity factor that comes out of the exit velocity algorithm. The value is divided by 100.

##### **x and z acceleration**

If the hit type is a bunt, these are set to 0.

Boo, King Boo, and Boomerang Bro have the Super Curve ability, which impacts this calculation. Line-drive star hits also have Super Curve.

##### Contact Spot Effect

Using the 0-200 scale used for contact, the game checks how close this value is to 100. For values over 100, subtract it from 200 to get the value on a 0 to 100 basis. Call this x.

Adjust this value closer to 100. Super Curve hits have a higher adjustment. The following is the formula for the Contact Effect.

Non-super curve: Contact Effect = 1 - (1 - x/100) \* 0.5

Super Curve: Contact Effect = 1 - (1 - x/100) \* 0.25

##### Launch Angle Effect

The curve is the most when the launch angle is 33.75 or less. Then, the effect decreases above that angle until 78.75 degrees where the curve is completely nullified.

Launch angle effect:

* Launch angle <= 33.75 -> 1
* 33.75 < Launch Angle <= 78.75 -> 1 - min(launch angle - 33.75, 45) / 45
* Launch angle > 78.75 -> 0

##### Horizontal Angle Effect

If the angle is outside of 22.5 and 157.5 degrees, default it to the closest angle.

If lefty, reverse the angle by subtracting from 180.

Now we convert to a number between -1 and 1, with -1 being the most pull-side curve, and 1 being the most push-side curve. 0 is centred at 8.4 degrees to the batters pull side (so 98.4 degrees for righties, and 81.6 degrees for lefties). The formula to convert to -1 to 1 is:

If horizontal angle < 98.4: Horizontal Angle Effect = (98.4-horizontal angle)/75.9

If horizontal angle >=98.4: Horizontal Angle Effect = (98.4-horizontal angle)/59.1

##### Determining final x and z acceleration

Combined curve effect = Contact Effect \* Launch Angle Effect \* Horizontal Angle Effect \* if(horizontal angle effect > 0, 1, -1)

Adjusted x component = cos(horizontal angle) \* if(horizontal angle effect > 0, -1, 1)

Adjusted z component = sin(horizontal angle) \* if(horizontal angle effect > 0, 1, -1)

x curve factor: 0.001 for non-super curve, 0.006 for super curve

z curve factor: 0.003 for non-super curve, 0.008 for super curve

**x acceleration**: Combined Curve effect \* Adjusted x component \* x curve factor [\* -1 if lefty]

**z acceleration**: Combined Curve effect \* Adjusted z component \* z curve factor [\* -1 if positive] {curve is always back towards home plate}