Skip to content

Instantly share code, notes, and snippets.

@bitwit
Created August 7, 2018 16:27
Show Gist options
  • Save bitwit/6e85156f4cfb43e549caed8859c5805d to your computer and use it in GitHub Desktop.
Save bitwit/6e85156f4cfb43e549caed8859c5805d to your computer and use it in GitHub Desktop.
Easy metric conversions for ARKit Floats using Int extensions
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