Created
June 30, 2019 14:26
-
-
Save alo9507/188e504229cf8f8ecde6c171d43bc469 to your computer and use it in GitHub Desktop.
get cardinal from yaw
This file contains 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
enum CardinalDirection: String { | |
case North = "North" | |
case South = "South" | |
case East = "East" | |
case West = "West" | |
case InBetween = "InBetween" | |
} | |
func getCardinalDirectionFromYaw(yaw: Double, accuracy: QuaternionAccuracy) { | |
let cardinalDirection: CardinalDirection | |
switch yaw { | |
case -45 ..< 45: | |
cardinalDirection = CardinalDirection.North | |
case 45 ..< 135: | |
cardinalDirection = CardinalDirection.East | |
case 135 ..< 180: | |
cardinalDirection = CardinalDirection.South | |
case -180 ..< -135: | |
cardinalDirection = CardinalDirection.South | |
case -135 ..< -45: | |
cardinalDirection = CardinalDirection.West | |
default: | |
cardinalDirection = CardinalDirection.InBetween | |
} | |
cardinalHeading.text = "Cardinal Heading: \(cardinalDirection.rawValue)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment