Skip to content

Instantly share code, notes, and snippets.

@leonardfactory
Created December 7, 2016 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardfactory/a4dff996ee9673c765139c2bba23f7be to your computer and use it in GitHub Desktop.
Save leonardfactory/a4dff996ee9673c765139c2bba23f7be to your computer and use it in GitHub Desktop.
/**
* Just a snippet, but it should work
*/
const {
roundedHeight,
height,
width
} = this.props;
const heightSq = Math.pow(roundedHeight - height, 2);
const widthSq = Math.pow(width / 2, 2);
const xSq = Math.pow(x, 2);
/**
* This will give `y` where 0 = same level as `height`. Maximum
* value is `roundedHeight`.
*/
let y = Math.round(Math.sqrt(heightSq * (1 - xSq/widthSq)));
@Ozerich
Copy link

Ozerich commented Dec 7, 2016

I think that formula is incorrect http://take.ms/169sa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment