-
-
Save robb/c125a8283cb9ed6725def210404920a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
func unitSquareIntersectionPoint(_ angle: Angle) -> UnitPoint { | |
let u = sin(angle.radians + .pi / 2) | |
let v = cos(angle.radians + .pi / 2) | |
let uSign = abs(u) / u | |
let vSign = abs(v) / v | |
if u * u >= v * v { | |
return UnitPoint( | |
x: 0.5 + 0.5 * uSign, | |
y: 0.5 + 0.5 * uSign * (v / u) | |
) | |
} else { | |
return UnitPoint( | |
x: 0.5 + 0.5 * vSign * (u / v), | |
y: 0.5 + 0.5 * vSign | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment