Skip to content

Instantly share code, notes, and snippets.

@itod
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save itod/ca07a59d5cdeebc6c122 to your computer and use it in GitHub Desktop.

Select an option

Save itod/ca07a59d5cdeebc6c122 to your computer and use it in GitHub Desktop.
Wave Function: 0.0-1.0, twice in 360º
// 0 == w:1.0 h:0.0
// 90 == w:0.0 h:1.0
// 180 == w:1.0 h:0.0
// 270 == w:0.0 h:1.0
// 360 == w:1.0 h:0.0
CGFloat rad = TDD2R(angle);
CGFloat wRatio = 0.5+(cos(2.0*rad)/2.0);
CGFloat hRatio = 1.0 - wRatio;
NSLog(@"angle: %g {w:%g, h:%g}", angle, wRatio, hRatio);
w = w * wRatio;
h = h * hRatio;
// 0 == w:1.0 h:0.0
// 45 == w:0.0 h:1.0
// 90 == w:1.0 h:0.0
// 135 == w:0.0 h:1.0
// 180 == w:1.0 h:0.0
CGFloat rad = TDD2R(angle);
CGFloat wRatio = 0.5+(cos(4.0*rad)/2.0);
CGFloat hRatio = 1.0 - wRatio;
NSLog(@"angle: %g {w:%g, h:%g}", angle, wRatio, hRatio);
@itod
Copy link
Copy Markdown
Author

itod commented Sep 13, 2014

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