- #1

mariano_donat

- 8

- 0

Code:

```
func launchAngle(speed: Float, distance: Float, yOffset: Float, gravity: Float, angle0: inout Float, angle1: inout Float) -> Bool {
angle0 = 0
angle1 = 0
let speedSquared = speed * speed
let operandA = powf(speed, 4)
let operandB = gravity * (gravity * (distance * distance) + (2 * yOffset * speedSquared))
if operandB > operandA {
return false
}
let root = sqrt(operandA - operandB)
angle0 = atan((speedSquared + root) / (gravity * distance))
angle1 = atan((speedSquared - root) / (gravity * distance))
return true
}
```