I am trying my hand at game physics.

I understand that the basic way to pull back a sphere when it collided is to negate the penetration distance:

```
// If collided...
// `distance`: distance form triangle face; a negative number
// `normal`  : triangle face, in vec3
// `position`: sphere center, in vec3
position.x -= normal.x * distance;
position.y -= normal.y * distance;
position.z -= normal.z * distance;

```

But I don't want to change y coordinate, while the player is on the ground like this (side view):

![aide view of the problem](https://i.stack.imgur.com/tjkbx.png)

How can I calculate the expected [translation](http://en.wikipedia.org/wiki/Translation_(geometry))?

I have these values:

* penetration distance, as a negative number (shown in blue)
* triangle face normal, as a `vec3` (shown in red)
* triangle vertices, as 3 `vec3`s

and

* sphere radius, as a number
* sphere center, as a `vec3`

Answers in any programing language are welcome!

**updated Jul 17, 2014**

I found a hint. It's difficult to explain, I will attach 2 more figures.  

It seems, dashed lines in following figures are the translation value what I need, I guess.

![](https://i.stack.imgur.com/dUZnw.png)

and in another case

![](https://i.stack.imgur.com/aKAJk.png)