Created
August 7, 2018 16:27
-
-
Save bitwit/6e85156f4cfb43e549caed8859c5805d to your computer and use it in GitHub Desktop.
Easy metric conversions for ARKit Floats using Int extensions
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
import ARKit | |
// Example usage: | |
// let twentyCentimeters: Float = 20.cm | |
// let twoMeters: Float = 2.m | |
// let oneMillimeter: Float = 1.mm | |
// let extent: float3 = float3(20.cm, 10.cm, 1.m) | |
extension Int { | |
var mm: Float { | |
return Float(self) / 1000 | |
} | |
var cm: Float { | |
return Float(self) / 100 | |
} | |
var m: Float { | |
return Float(self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment