cleanup self.

This commit is contained in:
Paul Zabelin
2018-01-04 07:37:02 -08:00
parent de8df37de9
commit adad1ecff8
3 changed files with 8 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ class PerformanceTest: XCTestCase {
) )
) )
self.measure { measure {
stride(from:0, to: 100000, by: 1).forEach { _ in stride(from:0, to: 100000, by: 1).forEach { _ in
_ = start.projectiveTransform(destination: destination) _ = start.projectiveTransform(destination: destination)
} }

View File

@@ -38,7 +38,7 @@ extension Matrix3x3Type {
func homogeneousInverse() -> Matrix3x3Type { func homogeneousInverse() -> Matrix3x3Type {
#if arch(arm64) || arch(x86_64) #if arch(arm64) || arch(x86_64)
let result = self.inverse let result = inverse
#else #else
let result = adjugate() let result = adjugate()
#endif #endif

View File

@@ -17,21 +17,21 @@ public final class Perspective {
lazy var basisVectorsToPointsMap: Matrix3x3Type! = { lazy var basisVectorsToPointsMap: Matrix3x3Type! = {
let m = Matrix3x3Type([ let m = Matrix3x3Type([
self.vectors[0], vectors[0],
self.vectors[1], vectors[1],
self.vectors[2]] vectors[2]]
) )
let solution = m.homogeneousInverse() * self.vectors[3] let solution = m.homogeneousInverse() * vectors[3]
let scale = Matrix3x3Type(diagonal: solution) let scale = Matrix3x3Type(diagonal: solution)
let basisToPoints = m * scale let basisToPoints = m * scale
return basisToPoints.zNormalized() return basisToPoints.zNormalized()
}() }()
lazy var pointsToBasisVectorsMap: Matrix3x3Type! = { lazy var pointsToBasisVectorsMap: Matrix3x3Type! = {
self.basisVectorsToPointsMap.homogeneousInverse() basisVectorsToPointsMap.homogeneousInverse()
}() }()
internal func projection(to:Perspective) -> Matrix3x3Type { internal func projection(to:Perspective) -> Matrix3x3Type {
return (to.basisVectorsToPointsMap * pointsToBasisVectorsMap).zNormalized() return (to.basisVectorsToPointsMap * pointsToBasisVectorsMap).zNormalized()
} }
} }