Optional Project 18: Finding Directrix and Focus from Equation

Optional Project 18:  Variables 'verticalParabola', 'a', 'vX', 'vY' have been initialized.

verticalParabola is true if the parabola opens up/down and false if the parabola opens left/right

a is the leading coefficient of the parabola

vX is the x-coordinate of the vertex

vY is the y-coordinate of the vertex

Task: Appropriately initialize 'directrix', 'focusX', 'focusY'

Some examples are shown below:

Given: 

verticalParabola = true

a = .5

vX = 3

vY = 4

The following would be initialized:

p = .5 (not required)     since a = ± 1/(4p)

focusX = 3

focusY = 4.5

directrix = 3.5 (which represents y = 3.5)

Given: 

verticalParabola = false

a = -1

vX = -5

vY = -4

The following would be initialized:

p = .25 (not required)     since a = ± 1/(4p)

focusX = -5.25

focusY = -4

directrix = -4.75 (which represents x = -4.75)

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0